Ejemplo n.º 1
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);
    }
Ejemplo n.º 2
0
 //Singlenton
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else if (Instance != this)
     {
         Destroy(this);
     }
     //   DontDestroyOnLoad(Instance);
 }
Ejemplo n.º 3
0
    /**
     * To create enemies in random position
     *
     * @see StaticExclusionArea#CheckCoordinatesSprite
     */
    private IEnumerator createEnemieRandomPlace <T>(int quantity) where T : Enemy
    {
        for (int h = 0; h < quantity; h++)
        {
            Vector3 a = createRandomCoordenates();

            //Check if the new coordinates are in the Sprite, in this case get new coordinates
            while (StaticExclusionArea.CheckCoordinatesSprite(a.x, a.y))
            {
                a = createRandomCoordenates();
            }

            //Use RecoveryEnemy to get new enemy (a die enemy or new instance)
            er.RecoveryEnemy <T>(a.x, a.y);

            yield return(new WaitForSeconds(timeBetweenEnemies));
        }
        yield return(new WaitForSeconds(timeBetweenEnemies));
    }
Ejemplo n.º 4
0
    /**
     * @see  StaticExclusionArea#AddNewSprite
     */
    private void Start()
    {
        spriteRenderExclusionArea = gameObject.GetComponent <SpriteRenderer>();

        StaticExclusionArea.AddNewSprite(spriteRenderExclusionArea);
    }
Ejemplo n.º 5
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);
                        }
                    }
                });
            }
        }
    }