Esempio n. 1
0
    /// <summary>
    /// Spawns a player on the netowrk. Responsible for spawning all things related to
    /// the player (the ball).
    /// </summary>
    /// <param name="code">The message data from the packets</param>
    internal void SpawnPlayerOnNetwork(string code)
    {
        string[] splitcode = code.Split(':');
        int      id        = int.Parse(splitcode[1]);
        int      team      = int.Parse(splitcode[2]);

        GameObject player = network.GetPlayerOfID(id);

        player      = Instantiate(_characterPrefab);
        player.name = id.ToString();
        player.GetComponent <PlayerScoreTracker>().Init(id);

        player.GetComponent <EnemyAnimation>().SetMaterial(network.GetMaterialOfPlayer(team));

        if (team == network.GetMyTeam())
        {
            EventController.FireEvent(new SetTeamUIMessage(player.transform));
        }

        Vector3 location = RespawnManager.instance.GetRespawnLocationAtIndex(id);

        player.GetComponent <EnemyHealth>().Respawn(location);
        player.GetComponent <EnemyHealth>().MyID = id;

        network.AddNumberOfConnectedPlayers();
        network.AddBallAndPlayerToNetwork(player, id);

        AbilityBall.Abilities off = (AbilityBall.Abilities)(NetworkStoredData.instance.GetOffenseAbility(id) + 1);
        AbilityBall.Abilities def = (AbilityBall.Abilities)(NetworkStoredData.instance.GetOffenseAbility(id) + 3);

        EventController.FireEvent(new InitializeAbilityBall(off, id));
        EventController.FireEvent(new InitializeAbilityBall(def, id));
        EventController.FireEvent(new InitializeAbilityBall(AbilityBall.Abilities.storageBall, id));
    }
Esempio n. 2
0
    private void SpawnAbilityBalls(AbilityBall.Abilities ability, int id)
    {
        int ballsToSpawn = 1;

        if (ability == AbilityBall.Abilities.storageBall)
        {
            ballsToSpawn = 5;
        }
        int index = id * maxNumberOfAbilityBalls + currentAbilityIndex[id];

        for (int i = 0; i < ballsToSpawn; ++i)
        {
            AbilityBall obj = Instantiate(abilityBallPrefabs[(int)ability]);
            obj.Initialize(this);
            obj.Despawn();
            abilityBalls[index] = obj;
            currentAbilityIndex[id]++;
            index++;
        }
    }
Esempio n. 3
0
 public InitializeAbilityBall(AbilityBall.Abilities ab, int id)
 {
     ability = ab;
     this.id = id;
 }
Esempio n. 4
0
 public AbilityBallPrepareMessage(PlayerController p, AbilityBall.Abilities ab, int id)
 {
     ability = ab;
     player  = p;
     slotID  = id;
 }