public SquareSSPositon(SSPosition lefttop, SSPosition leftbottom, SSPosition righttop, SSPosition rightbottom)
 {
     this.SquarePosition = new SSPosition[4];
     this.SquarePosition[0] = lefttop;
     this.SquarePosition[1] = leftbottom;
     this.SquarePosition[2] = righttop;
     this.SquarePosition[3] = rightbottom;
 }
Example #2
0
 public Entity()
 {
     this.position = new position.SSPosition();
     this.logger = Logger.GetInstance();
     this.ActionAI = new List<AITask>();
     this.MoveAI = new List<AITask>();
     this.AIEnabled = true;
     this.MoveSpeed = 1;
     this.isLiving = true;
     this.tempPos = new SSPosition();
 }
Example #3
0
 public void SetPosition(SSPosition pos)
 {
     this.position = new SSPosition();
     position.PosX = pos.PosX;
     position.PosY = pos.PosY;
 }
        /// <summary>
        /// 点が円の中にあるかどうか
        /// </summary>
        /// <param name="oppentPos"></param>
        /// <param name="myPos"></param>
        /// <param name="radius"></param>
        /// <returns></returns>
        private static bool PointCircleInteractHelper(SSPosition oppentPos, SSPosition myPos, int radius)
        {
            int dx = oppentPos.PosX - myPos.PosX;
            int dy = oppentPos.PosY - myPos.PosY;

            if (dx * dx + dy * dy < radius * radius)
                return true;
            else
                return false;
        }
        /// <summary>
        /// 角度θを返す
        /// </summary>
        /// <param name="squarePosition"></param>
        /// <param name="circlePosition"></param>
        /// <returns></returns>
        private static double GetThetaHelper(SSPosition pos0, SSPosition pos1, SSPosition circlePosition)
        {
            /* ベクトル C→P と C→Q のなす角θおよび回転方向を求める.*/
            Vector2 c, p, q; /* 入力データ */
            Vector2 cp;      /* ベクトル C→P */
            Vector2 cq;      /* ベクトル C→Q */
            double s;          /* 外積:(C→P) × (C→Q) */
            double t;          /* 内積:(C→P) ・ (C→Q) */
            double theta;      /* θ (ラジアン) */

            c = p = q = new Vector2();

            /* c,p,q を所望の値に設定する.*/
            c.x = pos0.PosX;
            c.y = pos0.PosY;
            p.x = pos1.PosX;
            p.y = pos1.PosY;
            q.x = circlePosition.PosX;
            q.y = circlePosition.PosY;

            /* 回転方向および角度θを計算する.*/
            cp = Vector2DiffHelper(p, c);          /* cp ← p - c   */
            cq = Vector2DiffHelper(q, c);          /* cq ← q - c   */
            s = Vector2OuterProductHelper(cp, cq); /* s ← cp × cq */
            t = Vector2InnerProductHelper(cp, cq); /* t ← cp ・ cq */
            theta = Math.Atan2(s, t);

            return theta;
        }
        /// <summary>
        /// 移動タイプを決定する
        /// </summary>
        public virtual void SetMoveType()
        {
            if (beforePosition == null)
            {
                this.beforePosition = new SSPosition(this.position.PosX, this.position.PosY);
                return;
            }

            if (this.position.PosX == this.beforePosition.PosX && this.beforePosition.PosY == this.position.PosY)
            {
                this.MoveType = MoveTypeEnum.Center;
                return;
            }

            if (this.position.PosX == this.beforePosition.PosX)
            {
                if (this.position.PosY > this.beforePosition.PosY)
                {
                    this.MoveType = MoveTypeEnum.Down;
                }
                else
                {
                    this.MoveType = MoveTypeEnum.Up;
                }
                return;
            }

            if (this.position.PosX > this.beforePosition.PosX)
            {
                if (this.beforePosition.PosY == this.position.PosY)
                {
                    this.MoveType = MoveTypeEnum.Right;
                    return;
                }

                if (this.beforePosition.PosY > this.position.PosY)
                {
                    this.MoveType = MoveTypeEnum.RightUp;
                    return;
                }

                if (this.beforePosition.PosY < this.position.PosY)
                {
                    this.MoveType = MoveTypeEnum.RightDown;
                    return;
                }
            }

            if (this.position.PosX < this.beforePosition.PosX)
            {
                if (this.beforePosition.PosY == this.position.PosY)
                {
                    this.MoveType = MoveTypeEnum.Left;
                    return;
                }

                if (this.beforePosition.PosY > this.position.PosY)
                {
                    this.MoveType = MoveTypeEnum.LeftUp;
                    return;
                }

                if (this.beforePosition.PosY < this.position.PosY)
                {
                    this.MoveType = MoveTypeEnum.LeftDown;
                    return;
                }
            }
        }