Example #1
0
        /// <summary>
        /// 생성자
        /// </summary>
        /// <param name="_animator"></param>
        /// <param name="_spriteRenderer"></param>
        public UnitState(UnitStateParameter _param)
        {
            m_Command = eUnitCommand.Idle;

            m_Parameter                  = new UnitStateParameter();
            m_Parameter.m_Unit           = _param.m_Unit;
            m_Parameter.m_SpriteRenderer = _param.m_SpriteRenderer;
            m_Parameter.m_Animator       = _param.m_Animator;
        }
Example #2
0
        /// <summary>
        /// 대기 상태로 설정
        /// </summary>
        public void SetToIdle()
        {
            m_Command = eUnitCommand.Idle;

            m_State = null;
            UnitStateParameter param = new UnitStateParameter();

            param.m_Unit           = this;
            param.m_SpriteRenderer = m_SpriteRenderer;
            param.m_Animator       = m_Animator;

            m_State = new UnitStateIdle(param);
            m_State.Draw();
        }
Example #3
0
        public override void OnClicked()
        {
            if (UnitManager.GetMovingPlayer() != null)
            {
                return;
            }

            // 이동 준비
            m_Command = eUnitCommand.ReadyToMove;
            Debug.Log("Ready To Move");

            UnitStateParameter param = new UnitStateParameter();

            param.m_Unit           = m_Parameter.m_Unit;
            param.m_SpriteRenderer = m_Parameter.m_Unit.m_SpriteRenderer;
            param.m_Animator       = m_Parameter.m_Unit.m_Animator;

            m_Parameter.m_Unit.m_State = null;
            m_Parameter.m_Unit.m_State = new UnitStateReadyToMove(param);
            m_Parameter.m_Unit.m_State.Draw();
        }
Example #4
0
        protected override void OnEnable()
        {
            base.OnEnable();

            m_Type = eCampType.Enemies;

            // 시작은 Idle로 시작
            m_Command = eUnitCommand.Idle;

            m_Direction = eDirection.West;

            m_State = null;
            UnitStateParameter param = new UnitStateParameter();

            param.m_Unit           = this;
            param.m_Animator       = m_Animator;
            param.m_SpriteRenderer = m_SpriteRenderer;

            m_State = new UnitStateIdle(param);
            m_State.Draw();
        }
        /// <summary>
        /// 이동
        /// </summary>
        /// <param name="_targetPosition">이동할 지점</param>
        public override void Move(Vector3Int _targetPosition)
        {
            base.Move(_targetPosition);

            m_Command = eUnitCommand.Move;

            // 이동 애니메이션을 보여준다.
            m_State = null;
            UnitStateParameter param = new UnitStateParameter();

            param.m_Unit           = this;
            param.m_SpriteRenderer = m_SpriteRenderer;
            param.m_Animator       = m_Animator;

            m_State = new UnitStateMove(param);
            m_State.Draw();


            HashSet <Vector3Int> path = Map.instance.m_TilemapPathFind.GetPath();

            // 이동할 방향 설정하고 왼쪽으로 이동할 경우, 스프라이트를 뒤집는다.
            Vector3Int firstPoint = path.First();
            Vector3Int lastPoint  = path.Last();

            if (lastPoint.x - firstPoint.x < 0)
            {
                m_Direction            = eDirection.West;
                m_SpriteRenderer.flipX = true;
            }
            else
            {
                m_Direction            = eDirection.East;
                m_SpriteRenderer.flipX = false;
            }

            // 실제로 목표 지점까지 이동
            MoveByPathTile(path, _targetPosition);
        }
Example #6
0
 public UnitStateIdle(UnitStateParameter _param)
     : base(_param)
 {
     m_Command = eUnitCommand.Idle;
 }
Example #7
0
 public UnitStateReadyToMove(UnitStateParameter _param)
     : base(_param)
 {
     m_Command = eUnitCommand.ReadyToMove;
 }
Example #8
0
 public UnitStateMove(UnitStateParameter _param)
     : base(_param)
 {
     m_Command = eUnitCommand.Move;
 }
Example #9
0
 public UnitStateReadyToAttack(UnitStateParameter _param)
     : base(_param)
 {
     m_Command = eUnitCommand.ReadyToAttack;
 }
 public UnitStateDie(UnitStateParameter _param)
     : base(_param)
 {
     m_Command = eUnitCommand.Die;
 }