Example #1
0
        internal void RespawnDuck(DuckPlayers ZeDuck)
        {
            Rigidbody[]  _duckRigidbodies = RSG.GetDuckRigidbodies();
            GameObject[] _duckSpawnPoints = RSG.GetDuckRespawnPoints();

            switch (ZeDuck)
            {
            case DuckPlayers.P1:
                _duckRigidbodies[0].gameObject.transform.position = _duckSpawnPoints[0].transform.GetChild(0).transform.GetChild(0).position;
                _duckRigidbodies[0].gameObject.transform.rotation = Quaternion.Euler(0, -45, 0);
                _duckRigidbodies[0].velocity = Vector3.zero;
                _duckRigidbodies[0].mass     = 1;
                Duck1Score = 0;
                mapController.RemoveAllOfOneColour(DuckPlayers.P1);
                break;

            case DuckPlayers.P2:
                _duckRigidbodies[1].gameObject.transform.position = _duckSpawnPoints[1].transform.GetChild(0).transform.GetChild(0).position;
                _duckRigidbodies[1].gameObject.transform.rotation = Quaternion.Euler(0, 140, 0);
                _duckRigidbodies[1].velocity = Vector3.zero;
                _duckRigidbodies[1].mass     = 1;
                Duck2Score = 0;
                mapController.RemoveAllOfOneColour(DuckPlayers.P2);
                break;

            default:
                break;
            }
        }
Example #2
0
 public void SetControlledHexagonsToUnlocked(DuckPlayers _duck)
 {
     for (int i = 0; i < mapHexagons.Length; i++)
     {
         if (mapHexagons[i].GetComponent <GridOBJ>())
         {
             if (mapHexagons[i].GetComponent <GridOBJ>().ControlledBy == _duck)
             {
                 mapHexagons[i].GetComponent <Renderer>().material.SetTexture("_BaseMap", defaultMaterial);
                 mapHexagons[i].GetComponent <GridOBJ>().LockHex = false;
             }
         }
     }
 }
Example #3
0
        private void OnTriggerEnter(Collider other)
        {
            if (other.gameObject.GetComponent <DuckScript>())
            {
                if (!hasPlayedSound)
                {
                    other.gameObject.GetComponent <DuckScript>().am.Play("RetroFX2", .5f);
                    hasPlayedSound = true;
                }

                duckToUse  = other.gameObject.GetComponent <DuckScript>().Ducks;
                duckColour = other.gameObject.GetComponent <DuckScript>().DuckColour;
                PaintHexagons();
            }
        }
Example #4
0
        private void Update()
        {
            if (RoundRunning)
            {
                bool isSet = false;
                GameTimer += Time.deltaTime;


                if (GameTimer > RoundLength)
                {
                    DuckPlayers RoundWinner = GetWinningDuck();

                    EndScreenButton.enabled = true;

                    Rigidbody[] _duckRigidbodies = RSG.GetDuckRigidbodies();

                    for (int i = 0; i < _duckRigidbodies.Length; i++)
                    {
                        // Duck Wins
                        if (_duckRigidbodies[i].gameObject.GetComponent <DuckScript>().Ducks == RoundWinner)
                        {
                            RSG.GlobalWarming.SetBool("IsWarming", false);
                            GameCan.enabled = false;
                            EndCan.enabled  = true;
                            _duckRigidbodies[i].gameObject.GetComponent <Rigidbody>().velocity = Vector3.zero;
                            _duckRigidbodies[i].gameObject.GetComponent <DuckScript>().enabled = false;
                            FindObjectOfType <RotateScript>().transform.position = _duckRigidbodies[i].transform.position;
                            FindObjectOfType <RotateScript>().Rotate             = true;
                            RoundRunning = false;
                            SetRounds(RoundWinner);
                            isSet = true;
                        }
                        // its a tie
                        if (!isSet)
                        {
                            GameCan.enabled = false;
                            EndCan.enabled  = true;
                            FindObjectOfType <RotateScript>().transform.position = GameObject.Find("EndCube").transform.position;
                            FindObjectOfType <RotateScript>().Rotate             = true;
                            RoundRunning = false;
                        }
                    }
                }
            }
        }
Example #5
0
        private void SetRounds(DuckPlayers Winner)
        {
            switch (Winner)
            {
            case DuckPlayers.P1:
                PlayerPrefs.SetInt("P1-Rounds", PlayerPrefs.GetInt("P1-Rounds") + 1);
                break;

            case DuckPlayers.P2:
                PlayerPrefs.SetInt("P2-Rounds", PlayerPrefs.GetInt("P2-Rounds") + 1);
                break;

            case DuckPlayers.None:
                break;

            default:
                break;
            }
        }
Example #6
0
        /// <summary>
        /// Removes all hexagons for the inputted duck...
        /// </summary>
        /// <param name="RemoveDuckColour">The Duck to change to</param>
        public void RemoveAllOfOneColour(DuckPlayers RemoveDuckColour)
        {
            for (int i = 0; i < mapHexagons.Length; i++)
            {
                if (mapHexagons[i].GetComponent <GridOBJ>())
                {
                    if (mapHexagons[i].GetComponent <GridOBJ>().ControlledBy == RemoveDuckColour)
                    {
                        mapHexagons[i].GetComponent <GridOBJ>().ControlledBy = DuckPlayers.None;
                        mapHexagons[i].GetComponent <Renderer>().material.SetColor("_BaseColor", defaultHexagonColor);

                        if (mapHexagons[i].GetComponent <Renderer>().material.GetTexture("_BaseMap") != defaultMaterial)
                        {
                            mapHexagons[i].GetComponent <Renderer>().material.SetTexture("_BaseMap", defaultMaterial);
                            mapHexagons[i].GetComponent <GridOBJ>().LockHex = false;
                        }
                    }
                }
            }
        }
Example #7
0
        public void SetDuckScoreToFinal(DuckPlayers Duck, int multiplier)
        {
            switch (Duck)
            {
            case DuckPlayers.P1:
                FinalDuck1Score += Duck1Score * multiplier;
                Duck1Score       = 0;
                mapController.RemoveAllOfOneColour(DuckPlayers.P1);
                mapController.ResetLockedHexagons();
                break;

            case DuckPlayers.P2:
                FinalDuck2Score += Duck2Score * multiplier;
                Duck2Score       = 0;
                mapController.RemoveAllOfOneColour(DuckPlayers.P2);
                mapController.ResetLockedHexagons();
                break;

            default:
                break;
            }
        }
Example #8
0
        private void SetColour(Color32 Input, DuckPlayers Player)
        {
            GetComponent <Renderer>().material.SetColor("_BaseColor", Input);
            ControlledBy = Player;

            switch (Player)
            {
            case DuckPlayers.P1:
                GM.Duck1Score = mapController.CalculateScores()[0];
                break;

            case DuckPlayers.P2:
                GM.Duck2Score = mapController.CalculateScores()[1];
                break;

            case DuckPlayers.None:
                break;

            default:
                break;
            }
        }
Example #9
0
 private void OnDisable()
 {
     duckToUse  = DuckPlayers.None;
     duckColour = Color.clear;
     StopAllCoroutines();
 }
Example #10
0
        private void OnTriggerEnter(Collider other)
        {
            if (other.gameObject.tag == "Waterie")
            {
                GetComponent <Renderer>().material.SetColor("_BaseColor", mapController.GetDefaultHexagonColor());
                IsSafe       = false;
                ControlledBy = DuckPlayers.None;

                if (other.GetComponent <DuckScript>())
                {
                    switch (other.GetComponent <DuckScript>().Ducks)
                    {
                    case DuckPlayers.P1:
                        GM.Duck1Score = mapController.CalculateScores()[0];
                        GM.Duck2Score = mapController.CalculateScores()[1];
                        break;

                    case DuckPlayers.P2:
                        GM.Duck1Score = mapController.CalculateScores()[0];
                        GM.Duck2Score = mapController.CalculateScores()[1];
                        break;

                    case DuckPlayers.None:
                        break;

                    default:
                        break;
                    }
                }
            }

            if (other.gameObject.tag != "Waterie")
            {
                if (IsSafe)
                {
                    if (!LockHex)
                    {
                        if (other.gameObject.GetComponent <DuckScript>())
                        {
                            SetColour(other.gameObject.GetComponent <DuckScript>().DuckColour, other.gameObject.GetComponent <DuckScript>().Ducks);
                        }
                        else if (other.gameObject.GetComponent <PaintCanScript>())
                        {
                            if (other.gameObject.GetComponent <PaintCanScript>().duckToUse != DuckPlayers.None)
                            {
                                SetColour(other.gameObject.GetComponent <PaintCanScript>().duckColour, other.gameObject.GetComponent <PaintCanScript>().duckToUse);
                            }
                        }
                    }
                    else
                    {
                        SetToUnLocked();
                    }

                    if (other.GetComponent <DuckScript>())
                    {
                        if (other.GetComponent <DuckScript>().LockHex)
                        {
                            SetToLocked();
                        }
                        else
                        {
                            SetToUnLocked();
                        }
                    }
                }
            }
        }
Example #11
0
 private void Start()
 {
     ControlledBy  = DuckPlayers.None;
     GM            = FindObjectOfType <GameManager>();
     mapController = FindObjectOfType <MapController>();
 }