示例#1
0
    private void UpdateCharacter()
    {
        GameObject go = Instantiate(characters.group[characterIndex].model, characterModel.transform.localPosition, characterModel.transform.localRotation);

        character = go;

        selected = go.GetComponent <MaterialManager>();
        selected.transform.localScale = characters.group[characterIndex].modelScale;

        // set team texture
        MaterialPack pack = characters.group[characterIndex].character.teamMaterials[teamIndex];

        selected.GetComponent <MaterialManager>().SetMaterialPack(pack);

        // bounce model
        BounceAnimation bounce = go.AddComponent <BounceAnimation>();

        bounce.duration = 0.5f;
        bounce.scale    = new Vector3(1.1f, 1.1f, 1.1f);
        bounce.Start();
        bounce.Animate();

        // set stats
        strength.texture = characters.group[characterIndex].strength;
        speed.texture    = characters.group[characterIndex].speed;
        weight.texture   = characters.group[characterIndex].weight;
        balance.texture  = characters.group[characterIndex].balance;
    }
示例#2
0
    private void SwitchTeamHandler(InputAction.CallbackContext context)
    {
        teamIndex += (int)context.ReadValue <float>();

        if (teamIndex < 0)
        {
            teamIndex = teams.group.Length - 1;
        }
        else if (teamIndex >= teams.group.Length)
        {
            teamIndex = 0;
        }

        //background.color = teams.group[index].color;
        background.texture = teams.group[teamIndex].teamBackground;
        label.text         = teams.group[teamIndex].name.ToString() + " TEAM";

        MaterialPack pack = characters.group[characterIndex].character.teamMaterials[teamIndex];

        selected.SetMaterialPack(pack);

        if (OnModeChange != null)
        {
            OnModeChange.Invoke();
        }

        // Play sound
        player.PlaySFX(switchAudio);
    }
示例#3
0
    // helper methods
    public void SetMaterialPack(MaterialPack pack)
    {
        currentPack = pack;

        currentPrimary = Instantiate(pack.primary);

        foreach (Renderer r in primary)
        {
            r.material = currentPrimary;
        }

        if (pack.secondary != null)
        {
            currentSecondary = Instantiate(pack.secondary);
            foreach (Renderer r in secondary)
            {
                r.material = currentSecondary;
            }
        }
    }
示例#4
0
    private void Start()
    {
        // exception handling
        if (players == null || players.Count == 0)
        {
            if (playerQueue.Count == 0)
            {
                Debug.LogError("Yo where the players at.");
                return;
            }
            else
            {
                players = playerQueue;
            }
        }

        Material playerBase = map.material;

        // spawn
        for (int i = 0; i < players.Count; ++i)
        {
            JoinInfo joinInfo = players[i];
            Team     team     = teams.group[joinInfo.team];
            // set map colour
            playerBase.SetColor("_Player" + (i + 1), team.color);
            // set player info
            Debug.Log(joinInfo.characterType);
            CharacterData data = characters.characters[joinInfo.characterType];
            // create game object accordingly
            Transform llama = Instantiate(data.characterPrefab).transform;
            // save llama rigidbody in list
            playerRBList.Add(llama.GetComponent <Rigidbody>());
            playerList.Add(llama);
            // Material
            MaterialPack pack = data.teamMaterials[joinInfo.team];
            llama.GetComponentInChildren <MaterialManager>().SetMaterialPack(pack);
            // Character info
            CharacterInfo info = llama.GetComponent <CharacterInfo>();
            info.playerID = i;
            info.team     = team.name;
            info.AI       = joinInfo.isAI;
            // Character position
            Vector3 position = bases.scoringArea[i].transform.position;
            position.y     = 1;
            llama.position = position;
            // Add to container
            llama.parent = container;
            llama.GetComponent <CharacterInput>().moveable = false;

            Cinematic camera = Instantiate(cameras[joinInfo.characterType]);
            camera.gameObject.active = true;
            camera.GetComponent <Camera>().enabled = false;
            foreach (Shot shot in camera.shots)
            {
                shot.target = llama.transform;
            }
            cameraContainer.cameras.Add(camera);
            camera.transform.parent = cameraContainer.transform;

            if (i < 2)
            {
                rotate.Add(llama);
            }
        }

        playerQueue.Clear();
        players.Clear();
    }