Example #1
0
    //Called by the Game.cs script when the game starts.
    public void SetStartValues()
    {
        //Sets the tank's stats based on the Game.cs start values.
        health          = game.tankStartHealth;
        maxHealth       = game.tankStartHealth;
        damage          = game.tankStartDamage;
        rocketDamage    = damage + 2;
        moveSpeed       = game.tankStartMoveSpeed;
        turnSpeed       = game.tankStartTurnSpeed;
        projectileSpeed = game.tankStartProjectileSpeed;
        reloadSpeed     = game.tankStartReloadSpeed;
        //Debug.Log("colours" + OpenGame.GetColorPlayer1() + "   " + OpenGame.GetColorPlayer2());
        if (MenuUI.getFlag() != 3)
        {
            game.player1Tank.GetComponent <SpriteRenderer>().color = OpenGame.GetColorPlayer1();
            game.player2Tank.GetComponent <SpriteRenderer>().color = OpenGame.GetColorPlayer2();
        }
        else
        {
            game.player1Tank.GetComponent <SpriteRenderer>().color = game.player1Color;
            game.player2Tank.GetComponent <SpriteRenderer>().color = game.player2Color;
        }

        game.playerMultiplayer.GetComponent <SpriteRenderer>().color = game.playerMultiplayerColor;
    }
Example #2
0
    void Start()
    {
        // player icon only in coop
        if (MenuUI.getFlag() == 3)
        {
            player1Im.GetComponent <Image>().sprite = OpenGame.GetPlayer1Sprite();    //set image sprite to the sprite player 1 has chosen
            player2Im.GetComponent <Image>().sprite = OpenGame.GetPlayer2Sprite();    //set image sprite to the sprite player 2 has chosen
        }

        // Create a temporary reference to the current scene.
        Scene currentScene = SceneManager.GetActiveScene();

        // Retrieve the name of this scene.
        string sceneName = currentScene.name;

        if (sceneName == "GameArena1" || sceneName == "vsPC")            //scenes with different arena maps
        //Load The Map
        {
            mapToLoad = PlayerPrefs.GetString("MapToLoad");
            TextAsset map = Resources.Load <TextAsset>("Maps/" + mapToLoad) as TextAsset;
            //Debug.Log(mapToLoad + "\n");
            //Debug.Log("    " + map.text + "   ");
            LoadMap(map.text);
        }
        else
        {
            //Load The Map
            mapToLoad = "Arena";
            TextAsset map = Resources.Load <TextAsset>("Maps/" + mapToLoad) as TextAsset;
            //Debug.Log(mapToLoad + "\n");
            //Debug.Log("    " + map.text + "   ");
            LoadStandardMap(map.text);
        }

        if (MenuUI.getFlag() != 1)
        {
            //Tank Bools
            player1Tank.canMove  = true;
            player1Tank.canShoot = true;

            player2Tank.canMove  = true;
            player2Tank.canShoot = true;

            //Tank Start Values
            player1Tank.SetStartValues();
            player2Tank.SetStartValues();

            ui.SetupHealthBars();
            if (MenuUI.getFlag() == 3)
            {
                //Tank Color
                player1Tank.GetComponent <SpriteRenderer>().color = OpenGame.GetColorPlayer1();   //player1Color;
                player2Tank.GetComponent <SpriteRenderer>().color = OpenGame.GetColorPlayer2();   //player2Color;
                //set players colors to the colors user has chosen
                player1Color = OpenGame.GetColorPlayer1();
                player2Color = OpenGame.GetColorPlayer2();

                if (OpenGame.colorChangePlayer1 == "green")             //green tank player 1
                //Debug.Log("green");
                {
                    player1Tank.damage++;                               //extra damage
                    player1Tank.reloadSpeed *= 2;                       //slower reload
                }
                else if (OpenGame.colorChangePlayer1 == "blue")         //blue tank player 1
                //Debug.Log("blue");
                {
                    player1Tank.moveSpeed   *= 2;                       //more move speed
                    player1Tank.turnSpeed   *= 2;                       //more turn speed
                    player1Tank.reloadSpeed *= 2;                       //slower reload
                }
                if (OpenGame.colorChangePlayer2 == "green")             //green tank player 2
                //Debug.Log("green ppplayer2");
                {
                    player2Tank.damage++;                               //extra damage
                    player2Tank.reloadSpeed *= 2;                       //more time to reload
                }
                else if (OpenGame.colorChangePlayer2 == "blue")         //blue tank player 2
                //Debug.Log("blue ppplayer2");
                {
                    player2Tank.moveSpeed   *= 2;                       //moves faster
                    player2Tank.turnSpeed   *= 2;                       //more speed at turns
                    player2Tank.reloadSpeed *= 2;                       //slower reload
                }
            }
            else
            {
                //Tank Color
                player1Tank.GetComponent <SpriteRenderer>().color = player1Color;
                player2Tank.GetComponent <SpriteRenderer>().color = player2Color;
            }
            //spawn points campaign
            if (MenuUI.getFlag() == 2)
            {
                player1Tank.transform.position = new Vector3(-48, -22, 0);
                player2Tank.transform.position = new Vector3(-3, 21, 0);
            }
            else
            {
                //set tank spawn position
                player1Tank.transform.position = spawnPoints[0].transform.position;
                player2Tank.transform.position = spawnPoints[1].transform.position;
            }
        }
        //else we are in multiplayer
        else
        {
            //spawnPlayer();
            //playerMultiplayer.gameObject.SetActive(true);
            ui.SetupHealthBars();
            //deactivate the usual coop - singleplayer tanks
            myObjectTank1.SetActive(false);
            myObjectTank2.SetActive(false);
        }
    }