示例#1
0
    public bool ShieldControl([Optional] bool shieldactive, [Optional] bool scaleshields, [Optional] bool resetShields)
    {
        GameObject myChild      = this.gameObject.transform.GetChild(0).gameObject;
        Vector3    scaleDefault = new Vector3(1.8f, 1.8f, 1.8f);

        if (shieldactive && !scaleshields && !resetShields)
        {
            _powerupTypes[2].powerupIsActive = shieldactive;
            myChild.SetActive(shieldactive);
            _ShieldBar.ShieldMax();
            return(_powerupTypes[2].powerupIsActive);
        }
        else if (shieldactive && scaleshields && !resetShields)
        {
            Vector3 scaleHold = myChild.transform.localScale;
            scaleHold -= new Vector3(0.2f, 0.2f, 0.2f);
            if (scaleHold.x <= 0.9f)
            {
                myChild.SetActive(false);
                myChild.transform.localScale = scaleDefault;
                _ShieldBar.ShieldReset();
                _powerupTypes[2].powerupIsActive = false;
            }
            else
            {
                myChild.transform.localScale = scaleHold;
                _ShieldBar.ShieldHit();
                _powerupTypes[2].powerupIsActive = shieldactive;
            }
            return(_powerupTypes[2].powerupIsActive);
        }
        else if (!shieldactive && !scaleshields && resetShields)
        {
            myChild.SetActive(shieldactive);
            myChild.transform.localScale = scaleDefault;
            _ShieldBar.ShieldReset();
            _powerupTypes[2].powerupIsActive = shieldactive;
            return(_powerupTypes[2].powerupIsActive);
        }
        else
        {
            return(_powerupTypes[2].powerupIsActive);
        }
    }
示例#2
0
    // Start is called before the first frame update
    void Start()
    {
        //Damage Object
        _fireDamage = GetComponentsInChildren <FireDamage>();
        //UNity Containers
        GameObject _PlayerContainer   = GameObject.FindGameObjectWithTag("SpawnManager").GetComponent <SpawnManager>().PlayerContainer;
        GameObject _LaserContainer    = GameObject.FindGameObjectWithTag("SpawnManager").GetComponent <SpawnManager>().LaserContainer;
        GameObject holdLaserContainer = GameObject.Find("Player Container");

        SetContainer(_PlayerContainer, _LaserContainer);
        //Thrusters
        _uiManager = GameObject.FindGameObjectWithTag("UIManager").GetComponent <UIManager>();
        //LivesCard
        _LivesCard = GameObject.FindGameObjectWithTag("LivesCard").GetComponent <LivesCard>();
        _LivesCard.RestSprite(true);
        //Default Shield OFF and Defaults
        this.gameObject.transform.GetChild(0).gameObject.SetActive(false);
        _shieldLive = _shieldMax;
        _ShieldBar  = GameObject.FindGameObjectWithTag("ShieldBar").GetComponent <ShieldBar>();
        _ShieldBar.ShieldReset();
        //Set play start position
        _livesHold = _playerInfo[0].playerLives;
        _speedHold = _playerInfo[0].playerSpeed;

        if (holdLaserContainer != null)
        {
            for (int i = 0; i < _laserTypes.Count; i++)
            {
                _laserTypes[i].LaserContainer = GameObject.Find("Player Container");
            }
        }
        else
        {
            Debug.Log("Startup Bug LaserContainer");
        }

        GameObject holdPowerContainer = GameObject.Find("Powerup Container");

        if (holdPowerContainer != null)
        {
            for (int i = 0; i < _laserTypes.Count; i++)
            {
                _powerupTypes[i].powerupContainer = GameObject.Find("Powerup Container");
            }
        }
        else
        {
            Debug.Log("Startup Bug PowerContainer");
        }
    }