Ejemplo n.º 1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (!Networking.PrimarySocket.IsServer)
        {
            return;             // Only do collision detection on the server.
        }
        Debug.Log("Bullet Trigger");
        Unit_Shooting us = other.GetComponent <Unit_Shooting> ();

        if (us != null)
        {
            if (shooterNetworkedIdSet)
            {
                if (us.NetworkedId == shooterNetworkedId)
                {
                    Debug.Log("Bullet Trigger self");
                }
                else
                {
                    Debug.Log("Bullet Trigger other");
                    // Hit another person! Woo!
                    other.GetComponent <Unit_Health> ().RPC("doDamage", damage);
                    Networking.Destroy(this);
                }
            }
            else
            {
                Debug.Log("BT unset");
            }
        }
    }
Ejemplo n.º 2
0
 public override void OnUpdate()
 {
     if (Input.GetKey(KeyCode.LeftAlt) && Input.GetKeyDown(KeyCode.Mouse2))
     {
         if (Physics.Raycast(Utils.GetLocalPlayerCamera().GetComponent <Camera>().ScreenPointToRay(Input.mousePosition), out RaycastHit hit))
         {
             Networking.SetOwner(Utils.GetLocalPlayer(), hit.collider.gameObject);
             Networking.Destroy(hit.collider.gameObject);
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Used to do final cleanup when disconnecting. This gets called currently on application quit and scene resets
        /// </summary>
        public virtual void Disconnect()
        {
            Cleanup();

            if (destroyOnDisconnect)
            {
                Networking.Destroy(this);
            }

            Unity.MainThreadManager.unityUpdate      -= UnityUpdate;
            Unity.MainThreadManager.unityFixedUpdate -= UnityFixedUpdate;
        }
Ejemplo n.º 4
0
    void Update()
    {
        if (Networking.PrimarySocket.IsServer)
        {
            lifespan -= Time.deltaTime;

            if (lifespan <= 0)
            {
                Networking.Destroy(this);
            }
        }
    }
Ejemplo n.º 5
0
        internal static void TogglePortals(bool state)
        {
            foreach (var i in Resources.FindObjectsOfTypeAll <PortalInternal>())
            {
                if (i != null)
                {
                    i.enabled = state;
                    i.gameObject.SetActive(state);

                    if (!state)
                    {
                        Networking.Destroy(i.gameObject);
                    }
                }
            }
        }
Ejemplo n.º 6
0
    private void Update()
    {
        if (destroy)
        {
            Networking.Destroy(this);
            return;
        }

        if (NetworkingManager.IsOnline && !OwningNetWorker.IsServer)
        {
            return;
        }

        // To check if we are dead
        if (_dead)
        {
            return;
        }

        if (Health <= 0)         // Zombie died!
        {
            _dead = true;
            Networking.Destroy(this);             // Destroy it! :)
        }
        else
        {
            ForgePlayer_Zombie closestPlayer = null;
            float dist = 100;             // Min distance

            // Check for the closest player
            foreach (ForgePlayer_Zombie player in ForgePlayer_Zombie.ZombiePlayers)
            {
                float distance = Vector3.Distance(player.transform.position, transform.position);
                if (distance < dist)
                {
                    closestPlayer = player;
                    dist          = distance;
                }
            }

            if (closestPlayer != null && dist > 2)             // Move towards the closest player
            {
                transform.position -= (transform.position - closestPlayer.transform.position) * Time.deltaTime;
            }
        }
    }
Ejemplo n.º 7
0
    public void OnTriggerEnter(Collider other)
    {
        if (NetworkingManager.IsOnline && !NetworkingManager.Socket.IsServer)
        {
            return;
        }

        if (other.gameObject.name.Contains("CubePlayerGuy"))
        {
            ForgePlayer_Zombie player = other.GetComponent <ForgePlayer_Zombie>();
            //A player hit this powerup!
            player.RPC("EnableRapidFire", NetworkReceivers.All);
            Debug.Log("Powerup Triggered for " + other.gameObject.name);

            Networking.Destroy(this);
        }
    }