예제 #1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.name.Equals("Player"))
        {
            Weapons w = weaponCatched.GetComponentInChildren <Weapons>();
            w.IsInPossesion = true;
            Weapons.TotalWeapons++;
            w.NumberThisWeapon = Weapons.TotalWeapons;

            if (StaticListWeapons.GetListAllWeapons().Count == 0)
            {
                weaponCatched.SetActive(true);
                w.IsActive = true;
            }
            else
            {
                weaponCatched.SetActive(false);
                w.IsActive = false;
            }

            StaticListWeapons.AddWeapon(w);

            ControlWeapons.Instance.AddNewWeaponCatched(weaponCatched);

            gameObject.SetActive(false);
        }
    }
예제 #2
0
    /**
     * method to return to the menu.
     *
     * This method clear the diferents statics arrays.
     */
    public void GoToMenu()
    {
        //Reset to control UI
        StaticListWeapons.ResetListWeapons();
        StaticExclusionArea.ResetListExclusionArea();

        SceneManager.LoadScene(1);
    }
예제 #3
0
 private void ChangeWeaponInUse()
 {
     StaticListWeapons.GetListAllWeapons().ForEach(w =>
     {
         if (w.IsActive)
         {
             w.gameObject.SetActive(true);
         }
         else
         {
             w.gameObject.SetActive(false);
         }
     });
 }
예제 #4
0
    //Return wich weapon (gameObject) is in possesion
    private List <Weapons> WhereWheaponsAreInPossesion()
    {
        List <Weapons> weaponsInPossesion = new List <Weapons>();

        foreach (Weapons w in StaticListWeapons.GetListAllWeapons())
        {
            if (w.GetComponent <Weapons>().IsInPossesion)
            {
                weaponsInPossesion.Add(w);
            }
        }

        return(weaponsInPossesion);
    }
예제 #5
0
    /**
     * Return what weapon (gameObject) IsActive
     */
    public int WhereIsTheActiveWeapon()
    {
        int activeWeapon = 0;

        foreach (Weapons w in StaticListWeapons.GetListAllWeapons())
        {
            if (w.GetComponent <Weapons>().IsActive)
            {
                activeWeapon = w.NumberThisWeapon;
            }
        }

        return(activeWeapon);
    }
예제 #6
0
    private void Update()
    {
        /*
         * if (Input.GetKeyDown(KeyCode.T))
         * {
         *  timeController.Seconds += 1;
         * }
         */


        if (!CanvasGamerOver.activeSelf)
        {
            CallAnimationRoundTimer();


            if (Input.GetKeyDown(KeyCode.Escape))
            {
                if (CanvasMenuEsc.activeSelf)
                {
                    CanvasMenuEsc.SetActive(false);
                }
                else
                {
                    CanvasMenuEsc.SetActive(true);
                }
            }

            //Player die || game over if the time event is 0
            if (playerStats.CurrentHealt <= 0 && writeBD)
            {
                IsNewScore           = false;
                timeToShowNewEnemies = 0;

                CanvasGamerOver.SetActive(true);

                SaveScoreAndTime(CurrentScore, timeController.getFormatTimer());

                FirebaseConnection.Instance.WriteScoreInBBDD(UserName, CurrentScore, timeController.getFormatTimer());

                //Reset to control UI
                StaticListWeapons.ResetListWeapons();
                StaticExclusionArea.ResetListExclusionArea();

                timeController.restartTimer();
                writeBD = false;
            }
        }

        CanWheelTiming();

        if (Input.mouseScrollDelta.y == 1.0f && canScroll)
        {
            int totalWeapons = ControlWeapons.Instance.TotalWeaponsInPossesion();
            int activeWeapon = ControlWeapons.Instance.WhereIsTheActiveWeapon();
            int nextWeapon   = 0;

            if (totalWeapons == activeWeapon)
            {
                nextWeapon = 1;
            }
            else
            {
                nextWeapon = activeWeapon + 1;
            }

            if (totalWeapons != 1)
            {
                StaticListWeapons.GetListAllWeapons().ForEach(w =>
                {
                    if (w.IsActive)
                    {
                        nextWeapon = w.NumberThisWeapon + 1;

                        w.IsActive = false;
                        w.gameObject.SetActive(false);
                    }

                    if (w.NumberThisWeapon == nextWeapon)
                    {
                        w.gameObject.SetActive(true);
                        w.IsActive = true;
                        ControlWeapons.Instance.UpdateActiveWeapon(w.NumberThisWeapon);
                    }
                });
            }
        }

        if (Input.mouseScrollDelta.y == -1.0f && canScroll)
        {
            int totalWeapons = ControlWeapons.Instance.TotalWeaponsInPossesion();
            int activeWeapon = ControlWeapons.Instance.WhereIsTheActiveWeapon();
            int nextWeapon   = 0;

            if (totalWeapons == activeWeapon)
            {
                nextWeapon = activeWeapon - 1;
            }
            else
            {
                nextWeapon = totalWeapons - 1;
            }

            if (nextWeapon == 0)
            {
                nextWeapon = totalWeapons;
            }

            if (totalWeapons != 1)
            {
                StaticListWeapons.GetListAllWeapons().ForEach(w =>
                {
                    if (w.IsActive)
                    {
                        nextWeapon = w.NumberThisWeapon - 1;
                        if (nextWeapon == 0)
                        {
                            nextWeapon = totalWeapons;
                        }

                        w.IsActive = false;
                        w.gameObject.SetActive(false);
                    }

                    if (w.NumberThisWeapon == nextWeapon)
                    {
                        w.gameObject.SetActive(true);
                        w.IsActive = true;
                        ControlWeapons.Instance.UpdateActiveWeapon(w.NumberThisWeapon);
                    }
                });
            }
        }



        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            StaticListWeapons.GetListAllWeapons().ForEach(w =>
            {
                if (w.IsInPossesion)
                {
                    //Active Weapon nº1
                    if (w.NumberThisWeapon == 1)
                    {
                        w.gameObject.SetActive(true);
                        w.IsActive = true;
                        ControlWeapons.Instance.UpdateActiveWeapon(w.NumberThisWeapon);
                    }
                    else
                    {
                        //Desactive all weapons
                        w.IsActive = false;
                        w.gameObject.SetActive(false);
                    }
                }
            });
        }

        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            if (Weapons.TotalWeapons > 1)
            {
                StaticListWeapons.GetListAllWeapons().ForEach(w =>
                {
                    if (w.IsInPossesion)
                    {
                        if (w.NumberThisWeapon == 2)
                        {
                            w.gameObject.SetActive(true);
                            w.IsActive = true;
                            ControlWeapons.Instance.UpdateActiveWeapon(w.NumberThisWeapon);
                        }
                        else
                        {
                            //Desactive all weapons
                            w.IsActive = false;
                            w.gameObject.SetActive(false);
                        }
                    }
                });
            }
        }
    }