コード例 #1
0
    // Start is called before the first frame update
    void Start()
    {
        lifePlayer = GameObject.FindGameObjectWithTag("Player").GetComponent <LifePlayer>();
        lifeEnemy  = GameObject.FindGameObjectWithTag("Enemy").GetComponent <LifeEnemy>();

        arrowSongDirections = Spawner.Instance.duel;

        originalSprite = this.GetComponent <SpriteRenderer>().sprite;
    }
コード例 #2
0
    void Shoot()
    {
        Transform t_spawn = transform.Find("Cameras/Main Camera");

        //bloom
        Vector3 t_bloom = t_spawn.position + t_spawn.forward * 1000f;

        t_bloom += Random.Range(-loadout[currentIndex].bloom, loadout[currentIndex].bloom) * t_spawn.up;
        t_bloom += Random.Range(-loadout[currentIndex].bloom, loadout[currentIndex].bloom) * t_spawn.right;
        t_bloom -= t_spawn.position;
        t_bloom.Normalize();

        //Raycast
        RaycastHit t_hit = new RaycastHit();

        if (Physics.Raycast(t_spawn.position, t_bloom, out t_hit, 1000f, canBeShot))
        {
            LifeEnemy turret = t_hit.transform.GetComponent <LifeEnemy>();
            if (turret)
            {
                turret.Altera(loadout[currentIndex].damage);
            }

            GameObject t_newHole = Instantiate(bulletHolePrefab, t_hit.point + t_hit.normal * 0.001f, Quaternion.identity) as GameObject;
            t_newHole.transform.LookAt(t_hit.point + t_hit.normal);
            Destroy(t_newHole, 5f);
        }

        //Gun FX
        currentWeapon.transform.Rotate(-loadout[currentIndex].recoil, 0, 0);
        currentWeapon.transform.position -= currentWeapon.transform.forward * loadout[currentIndex].kickback;

        //ammo
        loadout[currentIndex].currentAmmo--;

        //cooldown
        currentCooldown = loadout[currentIndex].firerate;
    }
コード例 #3
0
ファイル: Patrol.cs プロジェクト: Padilhaaa/Pane-no-Sistema
 void Start()
 {
     alvo  = FindObjectOfType <Player>().transform;
     agent = GetComponent <NavMeshAgent>();
     life  = GetComponent <LifeEnemy>();
 }
コード例 #4
0
 // Use this for initialization
 void Start()
 {
     life = GetComponent <LifeEnemy>();
 }
コード例 #5
0
 void Start()
 {
     spawn  = transform.Find("Spawn");
     player = FindObjectOfType <Player>().transform;
     life   = GetComponent <LifeEnemy>();
 }