Exemplo n.º 1
0
        void NotifyOwnerChanged()
        {
            try {
                OnOwnerChanged();
            } catch (Exception ex) {
                LoggingService.LogInternalError(ex);
            }

            if (extensionChain != null)
            {
                foreach (var ext in extensionChain.GetAllExtensions().OfType <DocumentControllerExtension> ().ToList())
                {
                    ext.RunOwnerChanged();
                }
            }

            OwnerChanged?.Invoke(this, EventArgs.Empty);
        }
Exemplo n.º 2
0
    void HandleInboundMessage(UdpMessage message)
    {
        switch (message.Event)
        {
        case "connected": Connected?.Invoke(); break;

        case "position": PositionUpdate?.Invoke(Deserialize <PositionUpdate>(message.Data.ToString())); break;

        case "newplayer": NewPlayer?.Invoke(new Guid(message.Data.ToString())); break;

        case "playerdisconnected": PlayerDisconnected?.Invoke(new Guid(message.Data.ToString())); break;

        case "newnetobj": NewNetObj?.Invoke(Deserialize <NetObj>(message.Data.ToString())); break;

        case "destroynetobj": NetObjDestroyed?.Invoke(new Guid(message.Data.ToString())); break;

        case "owner-changed": OwnerChanged?.Invoke(new Guid(message.Data.ToString())); break;

        default: Debug.LogError("Received invalid inbound message event: " + message.Event); break;
        }
    }
Exemplo n.º 3
0
        private void OnCollisionEnter2D(Collision2D collision)
        {
            ShipController ship = collision.gameObject.GetComponent <ShipController>();

            if (ship.Target != this)
            {
                return;
            }
            if (ship.OwnerID != OwnerID)
            {
                ShipsAmount -= ship.Damage;
                if (ShipsAmount <= 0)
                {
                    OwnerID     = ship.OwnerID;
                    ShipsAmount = Mathf.Abs(ShipsAmount);
                    OwnerChanged?.Invoke(this, OwnerID);
                }
            }
            else
            {
                ShipsAmount += ship.Damage;
            }
        }