Esempio n. 1
0
    IEnumerator Die()
    {
        dead = true;

        UpdateAnimatorState(AnimatorStateEnum.dead);
        //disable movement
        up    = stop;
        right = stop;
        down  = stop;
        left  = stop;


        float deadTime = characterAnimator.GetCurrentAnimatorStateInfo(0).length;

        yield return(new WaitForSeconds(deadTime));

        lifes--;

        transform.position = new Vector2(-666, 666);//move to hell

        if (!isClone && gameInfo.gameMode == GameModeEnum.Deathmatch && lifes <= 0)
        {
            weaponHandling.shootingEnabled = false;
            SoundManager.instance.PlaySingle(playerEliminatedSound);
            gameManager.CheckLifes();
        }
        else
        {
            dead = false;
            yield return(new WaitForSeconds(1f));

            hitPoints = maxHP;
            Vector3 newRandomPosition = posGenerator.GenerateRandomPosition();
            UpdatePosition();
            transform.position = newRandomPosition;

            //enable movement
            up    = Vector2.up;
            down  = Vector2.down;
            left  = Vector2.left;
            right = Vector2.right;

            //update weapon direction and stop player animation(AI reasons)
            RandomizeDirection();
            RefreshAnimatorState();
            UpdateDirection();
        }
    }
Esempio n. 2
0
    public void SpawnPowerUp()
    {
        var v = Enum.GetValues(typeof(PowerUpEnum));
        int i = UnityEngine.Random.Range(0, countOfPrefabedPowerUps);

        powerUpType = (PowerUpEnum)v.GetValue(i);

        for (int j = 0; j < pooledAmount; j++)
        {
            if (!powerUps[i][j].activeInHierarchy)
            {
                powerUps[i][j].transform.position = posGenerator.GenerateRandomPosition();
                powerUps[i][j].SetActive(true);
                break;
            }
        }

        SoundManager.instance.PlaySingle(itemSpawnSound);
    }
Esempio n. 3
0
    public void SpawnWeapon()
    {
        var v = Enum.GetValues(typeof(WeaponEnum));
        int i = UnityEngine.Random.Range(indexOfSpawnWeps, countOfWeapons);

        weaponType = (WeaponEnum)v.GetValue(i);
        i         -= indexOfSpawnWeps;

        for (int j = 0; j < pooledAmount; j++)
        {
            if (!weapons[i][j].activeInHierarchy)
            {
                weapons[i][j].transform.position = posGenerator.GenerateRandomPosition();
                weapons[i][j].SetActive(true);
                break;
            }
        }
        SoundManager.instance.PlaySingle(itemSpawnSound);
    }