Exemplo n.º 1
0
    void UpdateChangeType()
    {
        _switchCooldown -= Time.deltaTime;

        float changeColor = Input.GetAxisRaw("ChangeColor");

        if (changeColor > 0f && !_keyChangeColorLock)
        {
            if (_switchCooldown <= 0f)
            {
                ETypeShoot tmpType = _currentType;
                _currentType       = _clone._currentType;
                _clone.CurrentType = tmpType;

                UpdateColor();

                _switchCooldown = _switchTimer;
            }

            _keyChangeColorLock = true;
        }
        else if (changeColor == 0f && _keyChangeColorLock)
        {
            _keyChangeColorLock = false;
        }
    }
Exemplo n.º 2
0
    void UpdateShoot()
    {
        _shootCooldown -= Time.deltaTime;
        if (_shootCooldown <= 0f && Input.GetAxisRaw("Shoot") > 0f)
        {
            GameObject go = Instantiate(TypeManager.Instance.GetPlayerShoot(_currentType, _isClone), _muzzleTransform.position, _muzzleTransform.rotation);
            Destroy(go, 2.0f);

            _shootCooldown = _shootTimer;
        }

        //Alt fire on mouse two.  allow the plaer to shoot the alternate color by right clicking
        if (_shootCooldown <= 0f && Input.GetAxisRaw("Shoot2") > 0f)
        {
            //Get the alternate type...
            ETypeShoot cType = ETypeShoot.A;
            if (_currentType == ETypeShoot.A)
            {
                cType = ETypeShoot.B;
            }

            GameObject go = Instantiate(TypeManager.Instance.GetPlayerShoot(cType, _isClone), _muzzleTransform.position, _muzzleTransform.rotation);
            Destroy(go, 2.0f);

            _shootCooldown = _shootTimer;
        }
    }
Exemplo n.º 3
0
    public Sprite GetPlayerSprite(ETypeShoot t)
    {
        foreach (PlayerSpriteEntry e in PlayerSprite)
        {
            if (e.type == t)
            {
                return(e.value);
            }
        }

        return(null);
    }
Exemplo n.º 4
0
    /*
     * public Color GetPlayerColor(ETypeShoot t) {
     *      foreach (PlayerColorEntry e in PlayerColor) {
     *              if (e.type == t) {
     *                      return e.value;
     *              }
     *      }
     *      //return a rendering error color.  Null can't be used because color is a struct.  Or something...
     *      return Color.magenta;
     * }*/

    public GameObject GetPlayerShoot(ETypeShoot t, bool varient)
    {
        foreach (PlayerShootEntry e in PlayerShoot)
        {
            if (e.type == t)
            {
                if (!varient)
                {
                    return(e.value);
                }
                else
                {
                    return(e.value2);
                }
            }
        }

        return(null);
    }
Exemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        _elapsedTime += Time.deltaTime;
        _spawnTimer  -= Time.deltaTime;

        while (_spawnTimer <= 0f)
        {
            // Choose the player to spawn 0=player 1=clone
            int       player = Random.Range(0, 2);
            Transform transformPlayZone;
            if (player == 0)
            {
                transformPlayZone = _topLeftPosOfPlayerZone;
            }
            else
            {
                transformPlayZone = _topLeftPosOfCloneZone;
            }

            // Get the spawn position
            float   xToSpawn = Random.Range(0f, _widthPlayZone - _distanceFromEdges) + _distanceFromEdges / 2f;
            Vector3 spawnPos = new Vector3(xToSpawn + transformPlayZone.position.x, _distanceFromTopToSpawn + transformPlayZone.position.y, 0f);

            // Get a random rotation
            Quaternion spawnRot = Quaternion.AngleAxis(Random.Range(-Mathf.PI, Mathf.PI), Vector3.forward);

            // Get the right type to spawn
            GameObject meteor = null;
            ETypeShoot type   = (ETypeShoot)Random.Range(0, 2);
            switch (type)
            {
            case ETypeShoot.A: meteor = _meteorAPrefabs[Random.Range(0, _meteorAPrefabs.Length)]; break;

            case ETypeShoot.B: meteor = _meteorBPrefabs[Random.Range(0, _meteorAPrefabs.Length)]; break;
            }

            // Spawn
            Instantiate(meteor, spawnPos, spawnRot);

            _spawnTimer += ComputeTimer(_elapsedTime);
        }
    }