예제 #1
0
        void Start()
        {
            if (GetComponent <EnemyMoveRegister>() == null)
            {
                gameObject.AddComponent <EnemyMoveRegister>();
            }

            m_Collider2D.enabled   = false;
            m_SpriteRenderer.color = m_SpriteRenderer.color.WithAlpha(0f);

            var bounds = GameObject.FindGameObjectWithTag("Bounds").GetComponent <ScreenBounds>();

            m_MoveStates = new MovementState[4];

            if (initialMoveDir == MovementDirection.Left)
            {
                m_MoveStates[0] = new MoveLeft(bounds);
                m_MoveStates[2] = new MoveRight(bounds);
            }
            else
            {
                m_MoveStates[0] = new MoveRight(bounds);
                m_MoveStates[2] = new MoveLeft(bounds);
            }

            m_MoveStates[1] = new MoveDown(new Vector2(0f, -0.58f));
            m_MoveStates[3] = new MoveDown(new Vector2(0f, -0.58f));


            m_CurrentIndex = 0;

            m_CurrentState.Enter(transform);
        }
예제 #2
0
        void Start()
        {
            if (GetComponent <EnemyMoveRegister>() == null)
            {
                gameObject.AddComponent <EnemyMoveRegister>();
            }

            if (m_EnemyMovement.Count > 0)
            {
                var bounds = GameObject.FindGameObjectWithTag("Bounds").GetComponent <ScreenBounds>();

                m_MoveStates = new MovementState[4];

                if (moveDirection == MovementDirection.Right)
                {
                    m_MoveStates[0] = new MoveRight(bounds);
                    m_MoveStates[2] = new MoveLeft(bounds);
                }
                else if (moveDirection == MovementDirection.Left)
                {
                    m_MoveStates[0] = new MoveLeft(bounds);
                    m_MoveStates[2] = new MoveRight(bounds);
                }
                else
                {
                    Debug.LogWarning("No move state created for direction: " + moveDirection);
                    return;
                }

                m_MoveStates[1] = new MoveDown(new Vector2(0f, moveDown ? -0.54f : 0f));
                m_MoveStates[3] = new MoveDown(new Vector2(0f, moveDown ? -0.54f : 0f));
            }

            foreach (var enemy in m_EnemyMovement)
            {
                m_FadeIns.Add(enemy.gameObject.AddComponent <SpriteFadeIn>());
            }
        }