Exemple #1
0
        public override void UpdateTank()
        {
            // FSM, 상태머신,

            base.UpdateTank();

            //if (m_NextTick > Environment.TickCount)
            //{
            //    return;
            //}
            //m_NextTick = Environment.TickCount + (int)(Speed * 1000f);


            E_Driection movetype  = E_Driection.Max;
            Vector2     offsetpos = m_PlayerTank.CurrentPos - this.CurrentPos;

            if (Math.Abs(offsetpos.X) > Math.Abs(offsetpos.Y))
            {
                if (offsetpos.X < 0)
                {
                    movetype = E_Driection.Left;
                }
                else if (offsetpos.X > 0)
                {
                    movetype = E_Driection.Right;
                }

                //this.CurrentPos.X += offsetpos.X >= 0 ? 1 : -1;
            }
            else
            {
                if (offsetpos.Y < 0)
                {
                    movetype = E_Driection.Up;
                }
                else if (offsetpos.Y > 0)
                {
                    movetype = E_Driection.Down;
                }

                //this.CurrentPos.Y += offsetpos.Y > 0 ? 1 : -1;
            }

            if (movetype != E_Driection.Max)
            {
                this.Move(movetype);

                this.Fire();
            }
        }
Exemple #2
0
        public void Move(E_Driection p_direction)
        {
            switch (p_direction)
            {
            case E_Driection.Right:
            {
                if (!m_CurrentStageData.ISCollision(CurrentPos.X + 1, CurrentPos.Y))
                {
                    CurrentPos.X++;
                }
            }
            break;

            case E_Driection.Down:
            {
                if (!m_CurrentStageData.ISCollision(CurrentPos.X, CurrentPos.Y + 1))
                {
                    CurrentPos.Y++;
                }
            }
            break;

            case E_Driection.Left:
            {
                if (!m_CurrentStageData.ISCollision(CurrentPos.X - 1, CurrentPos.Y))
                {
                    CurrentPos.X--;
                }
            }
            break;

            case E_Driection.Up:
            {
                if (!m_CurrentStageData.ISCollision(CurrentPos.X, CurrentPos.Y - 1))
                {
                    CurrentPos.Y--;
                }
            }
            break;

            case E_Driection.Max:
            default:
            {
                //Debug.Write();
            }
            break;
            }

            m_DirectionVal = p_direction;
        }
Exemple #3
0
        public virtual void InitTankData(Vector2 p_initpos
                                         , E_Driection p_direction
                                         , ConsoleColor p_color = ConsoleColor.Green
                                         //, Stage p_stagedata
                                         //, InGameTank p_tankmanager
                                         )
        {
            m_DirectionVal     = p_direction;
            m_CurrentStageData = InGameTank.Instance().m_InGameStage;// p_stagedata;
            CurrentPos         = p_initpos;
            HP = 2;
            m_LinkInGameTank = InGameTank.GetI;

            m_Color = p_color;
        }
Exemple #4
0
        public void InitSetting(Vector2 p_pos
                                , E_Driection p_direction
                                , float p_movespeed)
        {
            MoveDirection = p_direction;
            CurrentPos    = p_pos;
            Speed         = p_movespeed;

            m_CurrentTick = Environment.TickCount;
            m_NextTick    = (int)(Speed * 1000f) + m_CurrentTick;

            switch (MoveDirection)
            {
            case E_Driection.Right:
                m_OffsetPos.X = 1;
                break;

            case E_Driection.Down:
                m_OffsetPos.Y = 1;
                break;

            case E_Driection.Left:
                m_OffsetPos.X = -1;
                break;

            case E_Driection.Up:
                m_OffsetPos.Y = -1;
                break;

            case E_Driection.Max:
            default:
                break;
            }

            //CurrentPos.X = CurrentPos.X + m_OffsetPos.X;
            //CurrentPos.Y = CurrentPos.Y + m_OffsetPos.Y;

            CurrentPos += m_OffsetPos;
        }
Exemple #5
0
        protected override void Initialze()
        {
            m_InGameStage = new Stage();
            m_InGameStage.InitStage();

            m_TankArray = new Tank[10];


            Vector2 pos = new Vector2();

            pos.Y = 5;
            pos.X = 5;

            m_MyTank = new Tank();
            m_MyTank.InitTankData(pos, E_Driection.Up);
            m_TankArray[0] = m_MyTank;
            m_MyTank.HP    = 1000;



            m_EnemyTank = new Tank();
            pos.Y       = 5;
            pos.X       = 3;
            m_EnemyTank.InitTankData(pos, E_Driection.Left, ConsoleColor.Red);
            m_TankArray[1] = m_EnemyTank;



            //EnemyTank tempenemytank = new EnemyTank();
            //tempenemytank.InitSettings();
            m_EnemyTank = new EnemyTank();
            pos.Y       = 5;
            pos.X       = 11;
            m_EnemyTank.InitTankData(pos, E_Driection.Right, ConsoleColor.Red);

            // (m_EnemyTank as EnemyTank).InitSettings();
            EnemyTank temptank = (m_EnemyTank as EnemyTank);

            if (temptank != null)
            {
                temptank.InitSettings(m_MyTank);
            }
            else
            {
                // 에러코드 적용
            }



            m_TankArray[2] = m_EnemyTank;



            m_ControlKeyDic.Add(ConsoleKey.UpArrow, E_Driection.Up);
            m_ControlKeyDic.Add(ConsoleKey.W, E_Driection.Up);
            m_ControlKeyDic.Add(ConsoleKey.NumPad8, E_Driection.Up);

            m_ControlKeyDic.Add(ConsoleKey.DownArrow, E_Driection.Down);
            m_ControlKeyDic.Add(ConsoleKey.S, E_Driection.Down);

            m_ControlKeyDic.Add(ConsoleKey.RightArrow, E_Driection.Right);
            m_ControlKeyDic.Add(ConsoleKey.D, E_Driection.Right);

            m_ControlKeyDic.Add(ConsoleKey.LeftArrow, E_Driection.Left);
            m_ControlKeyDic.Add(ConsoleKey.A, E_Driection.Left);


            E_Driection dic = m_ControlKeyDic[ConsoleKey.UpArrow];
        }