示例#1
0
 private void Start()
 {
     ContinueGame();
     GameOver.SetActive(false);
     RePlay.SetActive(false);
 }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        if (!death)
        {
            Life.GetComponent <RectTransform>().localScale   = new Vector3(life / 6f, 1, 1);
            Energy.GetComponent <RectTransform>().localScale = new Vector3(energy / 200f, 1, 1);
            Shield.GetComponent <RectTransform>().localScale = new Vector3(shield / 6f, 1, 1);
            Coin.GetComponent <Text>().text = ":" + coin;
            {//技能  已完善
                if (Input.GetMouseButtonDown(1))
                {
                    if (SkillTime <= 0)
                    {
                        SkillTime = skillTime;
                        skillGun  = (GameObject)Instantiate(mainWeapon);
                        skillGun.transform.parent                    = this.gameObject.transform;
                        skillGun.transform.localPosition             = new Vector3(0.1f, -0.05f, 0f);
                        skillGun.transform.localScale                = Vector3.one;
                        skillGun.GetComponent <WeaponPara>().isSleep = false;
                    }
                }
                if (SkillTime > 0)
                {
                    SkillTime -= Time.deltaTime;
                }
                else
                {
                    GameObject.Destroy(skillGun);
                    SkillTime = 0;
                }
            }



            {//伤害计算,毒伤计算
                if (PoisonTime > -0.1)
                {
                    PoisonTime -= Time.deltaTime;
                    i          -= Time.deltaTime;
                    if (i <= 0)
                    {
                        i       = 1f;
                        damage += 1;
                    }
                }

                if (damage > 0)
                {
                    if (shield - damage >= 0)
                    {
                        shield -= damage;
                    }
                    else
                    {
                        life  -= damage - shield;
                        shield = 0;
                    }
                    ReShieldTime = reShieldTime;
                    hurtAudio.Play();
                    damage = 0;
                }
            }
            {//生命与盾检测
                if (life <= 0)
                {
                    death = true;
                }
                if (ReShieldTime >= 0)
                {
                    ReShieldTime -= Time.deltaTime;
                }
                else if (shield < 6)
                {
                    if (t <= 0)
                    {
                        shield++;
                        t = 1f;
                    }
                    else
                    {
                        t -= Time.deltaTime;
                    }
                }
            }

            if (life <= 0)
            {
                death = true;//结束游戏,缺代码
                GameOver.SetActive(true);
                RePlay.SetActive(true);
            }
            {//交换主副手武器  已完善
                GameObject weapon;
                float      w = Input.GetAxis("Mouse ScrollWheel");
                if (w != 0)
                {
                    //播放音效
                    if (viceWeapon != null)
                    {
                        weapon     = mainWeapon;
                        mainWeapon = viceWeapon;
                        viceWeapon = weapon;
                        mainWeapon.SetActive(true);

                        viceWeapon.SetActive(false);//待测试,不知道行不行
                    }
                }
            }
        }
        else
        {
            anim.SetBool("isDeath", true);
            Life.GetComponent <RectTransform>().localScale = new Vector3(0, 1, 1);
            mainWeapon.GetComponent <WeaponPara>().isSleep = true;
        }
    }