コード例 #1
0
    void Start()
    {
        currentPos = transform.position;
        pathVisual = gameObject.GetComponent <LineRenderer>();

        groundHeight = new Vector2(0, 25);
        groundWidth  = new Vector2(0, 45);

        autofireHandling = GetComponent <Autofire>();
    }
コード例 #2
0
    public void ReceiveDamage(float damage, Autofire source)
    {
        hp          -= damage * (1 - cover);
        damageSource = source;
        if (hp <= 0)
        {
            isDead   = true;
            isFiring = false;
            if (tag == "Player")
            {
                GameObject[] playerCharacters       = GameObject.FindGameObjectsWithTag("Player");
                bool         isAnybodyAliveOutThere = false;
                foreach (GameObject playerCharacter in playerCharacters)
                {
                    if (!playerCharacter.GetComponent <Autofire>().isDead)
                    {
                        isAnybodyAliveOutThere = true;
                        break;
                    }
                }
                if (!isAnybodyAliveOutThere)
                {
                    GameManager.gameManager.Lose();
                }
            }
            if (tag == "Enemy")
            {
                GameObject[] enemyCharacters        = GameObject.FindGameObjectsWithTag("Enemy");
                bool         isAnybodyAliveOutThere = false;
                foreach (GameObject playerCharacter in enemyCharacters)
                {
                    if (!playerCharacter.GetComponent <Autofire>().isDead)
                    {
                        isAnybodyAliveOutThere = true;
                        break;
                    }
                }
                if (!isAnybodyAliveOutThere)
                {
                    GameManager.gameManager.Win();
                }
            }

            Destroy(fov);
            GetComponent <SpriteRenderer>().sprite = deathSprite;
            GetComponent <Animator>().enabled      = false;
            gameObject.layer = LayerMask.NameToLayer("Ignore Raycast");
        }
    }
コード例 #3
0
 public void DealDamage(Autofire target)
 {
     target.ReceiveDamage(damage * accuracy * Time.deltaTime, this);
 }