Пример #1
0
 public void Kill()
 {
     StaticStuff.score += scoreOnKill;
     StaticStuff.OnScoreChange();
     Destroy(gameObject);
 }
Пример #2
0
    private void Update()
    {
        float move = Input.GetAxisRaw("Horizontal") * Time.deltaTime * moveSpeed;

        cc.Move(Vector3.right * move);

        if (transform.position.x > moveRange)
        {
            transform.position = new Vector3(moveRange, transform.position.y, transform.position.z);
        }
        else if (transform.position.x < -moveRange)
        {
            transform.position = new Vector3(-moveRange, transform.position.y, transform.position.z);
        }

        if (transform.position.y != yPos)
        {
            transform.position = new Vector3(transform.position.x, yPos, transform.position.z);
        }


        if (regenTimer > 0)
        {
            regenTimer -= Time.deltaTime;
        }

        if (regenTimer <= 0)
        {
            regenTimer = hpRegenWait;
            if (health <= maxHealth - 1.0f)
            {
                Damage(-1.0f);
                StaticStuff.score += 1;
                StaticStuff.OnScoreChange();
            }
        }



        if (gunHeat > 0)
        {
            gunHeat -= Time.deltaTime;
        }

        if (gunHeat <= 0)
        {
            gunHeat = gunCooldown;

            GameObject o = bulletPool.GetObject();
            o.transform.position = transform.position;
            o.transform.rotation = transform.rotation;
            o.SetActive(true);
            o.GetComponent <PlayerBullet>().Shoot();

            o = bulletPool.GetObject();
            o.transform.position    = transform.position;
            o.transform.eulerAngles = transform.eulerAngles + new Vector3(0, sideBulletAngle, 0);
            o.SetActive(true);
            o.GetComponent <PlayerBullet>().Shoot();

            o = bulletPool.GetObject();
            o.transform.position    = transform.position;
            o.transform.eulerAngles = transform.eulerAngles + new Vector3(0, -sideBulletAngle, 0);
            o.SetActive(true);
            o.GetComponent <PlayerBullet>().Shoot();
        }
    }