// Learn cc.Class:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {

        StartPos: cc.v2(),
        NextPos1: cc.v2(),
        NextPos2: cc.v2(),
        NextPos3: cc.v2(),

    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start() {
        // this.width = 130;
        this._DrawParallelogramZone(new cc.Color(255, 255, 255, 100));

    },

    // update (dt) {},


    _DrawParallelogramZone(color) {
        var g = this.getComponent(cc.Graphics);

        g.lineWidth = 1;
        // g.fillColor.fromHEX('#ff0000');
        g.fillColor = color;
        // g.moveTo(-this.width, 0);
        // g.lineTo(0, -this.width * 0.5);
        // g.lineTo(this.width, 0);
        // g.lineTo(0, this.width * 0.5);

        g.moveTo(this.StartPos.x, this.StartPos.y);
        g.lineTo(this.NextPos1.x, this.NextPos1.y);
        g.lineTo(this.NextPos2.x, this.NextPos2.y);
        g.lineTo(this.NextPos3.x, this.NextPos3.y);

        g.close();

        g.stroke();
        g.fill();
    },
    //设置红色提示
    onSetRedSpriteFrame() {
        this.Tip.spriteFrame = this.Red;
    },


    //重新设置图片
    onReset() {
        this.Tip.spriteFrame = this.Green;
    }
});
