This zombie is created by the server and is only controlled by the server
Inheritance: BeardedManStudios.Network.NetworkedMonoBehavior
	public void Setup(ForgeZombie hitTarget, float lifespan)
	{
		_hitTarget = hitTarget;
		Lifespan = lifespan;
	}
Exemplo n.º 2
0
 public void Setup(ForgeZombie hitTarget, float lifespan)
 {
     _hitTarget = hitTarget;
     Lifespan   = lifespan;
 }
Exemplo n.º 3
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Networking.Disconnect();
        }

        if (Shooting)         //Local bullet shooting!
        {
            _timespan -= Time.deltaTime;
            if (_timespan <= 0)
            {
                _timespan = RapidFire ? _firingRate * 0.5f : _firingRate;

                float lifespan = 5;
                Ray   gunRay   = new Ray(transform.position, transform.forward);
#if !BARE_METAL
                ForgeZombie hitZombie = null;
#endif
                RaycastHit[] gunHit;
#if UNITY_EDITOR
                Debug.DrawRay(transform.position, transform.forward * 100, Color.green);
#endif

                gunHit = Physics.RaycastAll(gunRay, 100);
                if (gunHit != null && gunHit.Length > 0)
                {
                    foreach (RaycastHit hit in gunHit)
                    {
                        if (hit.collider != null)
                        {
                            if (hit.collider.name.Contains("Zombie"))
                            {
#if !BARE_METAL
                                hitZombie = hit.collider.GetComponent <ForgeZombie>();
#endif
                                //We hit a zombie! woot!
                                float distance = Vector3.Distance(transform.position, hit.collider.transform.position);
                                lifespan = distance * 0.02f;
                                break;
                            }
                        }
                    }
                }

#if !BARE_METAL
                //Shoot the bullet!
                Transform bullet = Instantiate(Bullet, transform.position + (transform.forward * 1.2f), transform.rotation) as Transform;

                if (hitZombie != null)
                {
                    bullet.GetComponent <ForgeZombieBullet>().Setup(hitZombie, lifespan);
                }
#endif
            }
        }

        if (RapidFire)
        {
            RapidFireTimespan -= Time.deltaTime;
            if (RapidFireTimespan <= 0)
            {
                RapidFireTimespan = 3;
                RapidFire         = false;
            }
        }
    }