Example #1
0
        public void StartStage(int stageIndex)
        {
            _currentStage = stageIndex;
            StageScript stage = _stages[_currentStage];

            // Collecting respawnable objects.
            List <RespawnScript> players = new List <RespawnScript>();

            foreach (TeamMember member in _players)
            {
                players.Add(member.GetComponent <RespawnScript>());
            }
            RespawnScript ball = _ball.GetComponent <RespawnScript>();

            // Setting new respawn locations.
            for (int i = 0; i < players.Count; i++)
            {
                players[i].SetSpawnLocation(stage.GetPlayerSpawnLocations()[i]);
            }
            ball.SetSpawnLocation(stage.GetBallSpawnLocation());

            // Respawn respawnable objects.
            players.ForEach(player => player.Respawn());
            ball.Respawn();

            Camera.main.transform.position = stage.GetCameraLocation();
        }
Example #2
0
        private void OnTriggerEnter(Collider other)
        {
            if (other.gameObject.tag.Equals(Tag.BALL.GetTagId()))
            {
                Ball          ball    = other.gameObject.GetComponent <Ball>();
                RespawnScript respawn = other.gameObject.GetComponent <RespawnScript>();

                Score(ball.GetLastTouchingPlayer());
                ball.SetLastTouched(null);
                respawn.Respawn();
            }
            else if (other.gameObject.tag.Equals(Tag.PLAYER.GetTagId()))
            {
                RespawnScript respawn = other.gameObject.GetComponent <RespawnScript>();
                respawn.Respawn();
            }
        }