Esempio n. 1
0
        /// <summary>
        /// 计算旋转后的新坐标
        /// </summary>
        /// <param name="angle"></param>
        /// <param name="rotate"></param>
        /// <param name="oldpxy"></param>
        /// <returns></returns>
        private pXY CalcRoateXy(int angle, RotateFlag rotate, pXY oldpxy)
        {
            pXY    newpxy = new pXY();
            double radx   = Angel2Pi(angle);
            double x1     = oldpxy.X * Math.Cos(radx);
            double x2     = oldpxy.Y * Math.Sin(radx);

            double y1 = oldpxy.Y * Math.Cos(radx);
            double y2 = oldpxy.X * Math.Sin(radx);

            if (rotate == RotateFlag.EASTERN)
            {
                newpxy.X = Math.Round((x1 - x2), 0);
                newpxy.Y = Math.Round((y1 + y2), 0);
            }

            if (rotate == RotateFlag.CLOCKWISE)
            {
                newpxy.X = Math.Round((x1 + x2), 0);
                newpxy.Y = Math.Round((y1 - y2), 0);
            }



            return(newpxy);
        }
Esempio n. 2
0
 private void radClockwise_CheckedChanged(object sender, EventArgs e)
 {
     if (radClockwise.Checked)
     {
         _ROTATE = RotateFlag.CLOCKWISE;
     }
     if (radEastern.Checked)
     {
         _ROTATE = RotateFlag.EASTERN;
     }
 }
Esempio n. 3
0
    void Start()
    {
        EventMgr <GameEvent> .instance.AddListener(GameEvent.Feed, OnFeed);

        EventMgr <GameEvent> .instance.AddListener(GameEvent.FoodDestroy, OnFoodDestroy);

        _tr               = transform;
        _tr.parent        = Tank.instance.gameObject.transform;
        move              = new MoveFlag(_tr);
        speed             = new SpeedFlag(_tr);
        rota              = new RotateFlag(_tr);
        feed              = new FeedFlag(_tr);
        anim              = new AnimFlag(_tr);
        feed.feedDuration = feedDuration;
        RandomBorn();
        SpeedOver();
    }