private void DoShot(ShotState state)
        {
            GameObject  go         = (GameObject)Instantiate(Shot, transform.position, Quaternion.identity);
            ShootFlying shotFlying = go.GetComponent <ShootFlying> ();

            switch (state)
            {
            case ShotState.DOWN:
                // Set flying direction and revert CoRoutineRunningValue
                shotFlying.FlyDown     = true;
                CoRoutineIsRunningDown = false;
                break;

            case ShotState.LEFT:
                shotFlying.FlyLeft     = true;
                CoRoutineIsRunningLeft = false;
                break;

            case ShotState.RIGHT:
                shotFlying.FlyRight     = true;
                CoRoutineIsRunningRight = false;
                break;

            case ShotState.UP:
                shotFlying.FlyUp     = true;
                CoRoutineIsRunningUp = false;
                break;
            }
        }
Example #2
0
        void Update()
        {
            if (Input.GetButtonDown(EnemyAWConst.FIRE))
            {
                GameObject  go          = (GameObject)Instantiate(Bullet, transform.position, Quaternion.identity);
                ShootFlying shootFlying = go.GetComponent <ShootFlying>();

                if (myPlayerController.facingRight)
                {
                    shootFlying.FlyRight = true;
                }
                else
                {
                    shootFlying.FlyLeft = true;
                }
            }
        }