Example #1
0
    void Start()
    {
        if (GlobalGameManager.GetPlayerGamepad(player) == -1)
        {
            if (playerGui != null)
            {
                Destroy(playerGui.gameObject);
            }
            Destroy(gameObject);
        }

        currentHealth = maxHealth;
        boost         = maxBoost;

        Destroy(Visual);
        Visual = (GameObject)Instantiate(ShipManager.instance.ships[GlobalGameManager.GetPlayerShip(player)]);
        Visual.transform.parent        = transform;
        Visual.transform.localPosition = Vector3.zero;
        Visual.transform.localScale    = Vector3.one;
        Visual.GetComponent <ShipVisuals>().UpdateVisuals(ShipManager.instance.GetColor(player));
        ShieldObject.GetComponentInChildren <ParticleSystem>().startColor = ShipManager.instance.GetColor(player);

        if (playerGui != null)
        {
            playerGui.SetupBars(maxHealth, maxBoost, ShipManager.instance.GetColor(player));
            playerGui.UpdateBars(currentHealth, boost);
        }
    }
    // Update is called once per frame
    public void UpdateVisual(int playerId, bool joined, bool ready)
    {
        Destroy(shipDisplay);

        if (joined)
        {
            ReadyBG.color = ready?Color.green:readyBgOriginal;

            shipDisplay = (GameObject)Instantiate(ShipManager.instance.ships[GlobalGameManager.GetPlayerShip(playerId)]);
            shipDisplay.GetComponent <ShipVisuals>().UpdateVisuals(ShipManager.instance.GetColor(playerId));
            shipDisplay.transform.parent        = shipDisplayParent;
            shipDisplay.transform.localScale    = Vector3.one;
            shipDisplay.transform.localPosition = Vector3.zero;

            ShipColor.color = ShipManager.instance.GetColor(playerId);
        }
        else
        {
            ShipColor.color = Color.grey;
            ReadyBG.color   = readyBgOriginal;
        }
    }
Example #3
0
    void CheckShipSelect()
    {
        if (p1joined && !p1Ready)
        {
            float inputY  = InputManager.Player1.LeftY;
            int   Pnumber = GlobalGameManager.GetPlayerNumber(1);
            if (inputY > 0.1f)
            {
                if (!p1changed)
                {
                    GlobalGameManager.SelectNewShip(Pnumber, GlobalGameManager.GetPlayerShip(Pnumber) + 1);
                    p1changed = true;
                    UpdateVisuals(1);
                }
            }
            else
            if (inputY < -0.1f)
            {
                if (!p1changed)
                {
                    GlobalGameManager.SelectNewShip(Pnumber, GlobalGameManager.GetPlayerShip(Pnumber) - 1);
                    p1changed = true;
                    UpdateVisuals(1);
                }
            }
            else
            {
                p1changed = false;
            }
        }

        if (p2joined && !p2Ready)
        {
            float inputY  = InputManager.Player2.LeftY;
            int   Pnumber = GlobalGameManager.GetPlayerNumber(2);
            if (inputY > 0.1f)
            {
                if (!p2changed)
                {
                    GlobalGameManager.SelectNewShip(Pnumber, GlobalGameManager.GetPlayerShip(Pnumber) + 1);
                    p2changed = true;
                    UpdateVisuals(2);
                }
            }
            else
            if (inputY < -0.1f)
            {
                if (!p2changed)
                {
                    GlobalGameManager.SelectNewShip(Pnumber, GlobalGameManager.GetPlayerShip(Pnumber) - 1);
                    p2changed = true;
                    UpdateVisuals(2);
                }
            }
            else
            {
                p2changed = false;
            }
        }

        if (p3joined && !p3Ready)
        {
            float inputY  = InputManager.Player3.LeftY;
            int   Pnumber = GlobalGameManager.GetPlayerNumber(3);
            if (inputY > 0.1f)
            {
                if (!p3changed)
                {
                    GlobalGameManager.SelectNewShip(Pnumber, GlobalGameManager.GetPlayerShip(Pnumber) + 1);
                    p3changed = true;
                    UpdateVisuals(3);
                }
            }
            else
            if (inputY < -0.1f)
            {
                if (!p3changed)
                {
                    GlobalGameManager.SelectNewShip(Pnumber, GlobalGameManager.GetPlayerShip(Pnumber) - 1);
                    p3changed = true;
                    UpdateVisuals(3);
                }
            }
            else
            {
                p3changed = false;
            }
        }

        if (p4joined && !p4Ready)
        {
            float inputY  = InputManager.Player4.LeftY;
            int   Pnumber = GlobalGameManager.GetPlayerNumber(4);
            if (inputY > 0.1f)
            {
                if (!p4changed)
                {
                    GlobalGameManager.SelectNewShip(Pnumber, GlobalGameManager.GetPlayerShip(Pnumber) + 1);
                    p4changed = true;
                    UpdateVisuals(4);
                }
            }
            else
            if (inputY < -0.1f)
            {
                if (!p4changed)
                {
                    GlobalGameManager.SelectNewShip(Pnumber, GlobalGameManager.GetPlayerShip(Pnumber) - 1);
                    p4changed = true;
                    UpdateVisuals(4);
                }
            }
            else
            {
                p4changed = false;
            }
        }
    }