public void InstantiateMissileAtLocation(List <Missile> missiles, int x, int y, float rate)
        {
            float interval = 0.15f;

            for (int m = 0; m < missiles.Count; m++)
            {
                float z = y;
                if (m > 0 && m % 2 == 0)
                {
                    z += m * interval;
                }
                else
                {
                    z += m * interval;
                }

                PlayerType missilePlayerType = missiles [m].PlayerType;
                int        direction         = missilePlayerType == PlayerType.A ? 1 : -1;

                var missile = missilePlayerType == PlayerType.A ?
                              MissileObjectPool.current.GetForPlayerA() :
                              MissileObjectPool.current.GetForPlayerB();

                missile.SetActive(true);
                missile.transform.position = new Vector3(x, missile.transform.position.y, z);
                MissileController missileCtrl = missile.GetComponent <MissileController>();
                missileCtrl.Setup(missiles[m], direction, rate);

                if (IsNewMissile(missileCtrl.missile))
                {
                    // Play muzzleflash effect
                    var pos = missile.transform.position;

                    var offset      = missileCtrl.missile.PlayerType == PlayerType.A ? -0.5f : 0.25f;
                    var muzzleFlash = missileCtrl.missile.PlayerType == PlayerType.A ? muzzleFlashPlayerA : muzzleFlashPlayerB;

                    pos.x -= direction * missileCtrl.missile.Speed + offset;
                    pos.y  = 0.5f;
                    var muzzleFlashObj = Instantiate(muzzleFlash, pos, Quaternion.identity);
                    Destroy(muzzleFlashObj, CommandLineUtil.GetRoundStep());

                    AudioClip clip;

                    if (missileCtrl.missile.PlayerType == PlayerType.A)
                    {
                        clip = firingSoundsPlayerA[Random.Range(0, firingSoundsPlayerA.Length)];
                    }
                    else
                    {
                        clip = firingSoundsPlayerB[Random.Range(0, firingSoundsPlayerB.Length)];
                    }

                    missileCtrl.PlaySound(clip);
                }
            }
        }
        void Start()
        {
            roundStepTime = CommandLineUtil.GetRoundStep();

            Instantiator  instantiator  = GetComponent <Instantiator> ();
            UIManager     uiManager     = GameObject.FindGameObjectWithTag(Constants.Tags.UIHolder).GetComponent <UIManager> ();
            ReplayManager replayManager = GetComponent <ReplayManager> ();

            gameStateManager = new GameStateManager(startRound, this, uiManager, instantiator, replayManager);

            AttemptToStartReplay();
        }
Beispiel #3
0
        void Awake()
        {
            audioSource = GetComponent <AudioSource> ();

            gameSpeed = CommandLineUtil.GetRoundStep();

            constructionModel.SetActive(false);
            model.SetActive(true);

            if (HealthBar != null)
            {
                HealthBar.MaxHealth = MaxHealth;
            }
        }
Beispiel #4
0
        public GameStateManager(int startRound, GameManager gameManager, UIManager uiManager, Instantiator instantiator, ReplayManager replayManager)
        {
            this.startRound    = startRound;
            this.gameManager   = gameManager;
            this.instantiator  = instantiator;
            this.uiManager     = uiManager;
            this.replayManager = replayManager;

            currentRound = startRound;
            rate         = CommandLineUtil.GetRoundStep();

            previousMissiles = new List <string>();

            Initialise();
        }
        private void InstantiateLightningHit(PlayerType originPlayer, GameObject start, GameObject end)
        {
            var lightningToInstantiate = originPlayer == PlayerType.A ? lightningBoltA : lightningBoltB;

            var lightningBoltObj          = Instantiate(lightningToInstantiate);
            var lightningBoltScript       = lightningBoltObj.GetComponent <LightningBoltScript>();
            var lightningBoltLineRenderer = lightningBoltObj.GetComponent <LineRenderer>();

            lightningBoltLineRenderer.startWidth = 0.15f;
            lightningBoltLineRenderer.endWidth   = 0.15f;

            lightningBoltScript.StartObject = start;
            lightningBoltScript.EndObject   = end;

            Destroy(lightningBoltObj, CommandLineUtil.GetRoundStep());

            var explosionToInstantiate = originPlayer == PlayerType.B ? explosionA : explosionB;
            var expObj = Instantiate(explosionToInstantiate, start.transform.position, Quaternion.identity);

            expObj.transform.localScale = expObj.transform.localScale * 0.5f;
        }