示例#1
0
    public static RequestGameAction Send(IServerActionGUI iServerActionGUI)
    {
        var  netObject          = (iServerActionGUI as Component).GetComponent <NetworkIdentity>();
        var  _ComponentType     = iServerActionGUI.GetType();
        var  iServerActionGUIs  = netObject.GetComponentsInChildren(_ComponentType);
        var  _ComponentLocation = 0;
        bool Found = false;

        foreach (var _iServerActionGUI in iServerActionGUIs)
        {
            if ((_iServerActionGUI as IServerActionGUI) == iServerActionGUI)
            {
                Found = true;
                break;
            }
            _ComponentLocation++;
        }
        if (Found)
        {
            RequestGameAction msg = new RequestGameAction
            {
                NetObject         = netObject.netId,
                ComponentLocation = _ComponentLocation,
                ComponentType     = _ComponentType,
            };
            msg.Send();
            return(msg);
        }
        else
        {
            Logger.LogError("Failed to find IServerActionGUI on NetworkIdentity");
        }
        return(null);
    }
示例#2
0
    private static SetActionUI _Send(GameObject recipient,
                                     IServerActionGUI iServerActionGUI,
                                     SetActionUIActions ProposedAction,
                                     bool _showAlert = false,
                                     int location    = 0)
    {
        if (!(iServerActionGUI is UIActionScriptableObject))
        {
            var  netObject          = (iServerActionGUI as Component).GetComponent <NetworkIdentity>();
            var  _ComponentType     = iServerActionGUI.GetType();
            var  iServerActionGUIs  = netObject.GetComponentsInChildren(_ComponentType);
            var  _ComponentLocation = 0;
            bool Found = false;
            foreach (var _iServerActionGUI in iServerActionGUIs)
            {
                if ((_iServerActionGUI as IServerActionGUI) == iServerActionGUI)
                {
                    Found = true;
                    break;
                }

                _ComponentLocation++;
            }

            if (Found)
            {
                SetActionUI msg = new SetActionUI
                {
                    NetObject         = netObject.netId,
                    ComponentLocation = _ComponentLocation,
                    ComponentType     = _ComponentType,
                    showAlert         = _showAlert,
                    SpriteLocation    = location,
                    ProposedAction    = ProposedAction
                };
                msg.SendTo(recipient);
                return(msg);
            }
            else
            {
                Logger.LogError("Failed to find IServerActionGUI on NetworkIdentity");
            }
        }
        else
        {
            var         _ComponentType = iServerActionGUI.GetType();
            SetActionUI msg            = new SetActionUI
            {
                soID           = UIActionSOSingleton.ActionsTOID[(iServerActionGUI as UIActionScriptableObject)],
                showAlert      = _showAlert,
                SpriteLocation = location,
                ProposedAction = ProposedAction,
                ComponentType  = _ComponentType,
            };
            msg.SendTo(recipient);
            return(msg);
        }

        return(null);
    }
示例#3
0
    public override void Process()
    {
        IServerActionGUI IServerActionGUI = null;

        if (soID != 0)
        {
            IServerActionGUI = UIActionSOSingleton.Instance.ReturnFromID(soID);
        }
        else
        {
            LoadNetworkObject(NetObject);
            var IServerIActionGUIs = NetworkObject.GetComponentsInChildren(ComponentType);
            if ((IServerIActionGUIs.Length > ComponentLocation))
            {
                IServerActionGUI = (IServerIActionGUIs[ComponentLocation] as IServerActionGUI);
            }
        }

        if (IServerActionGUI != null)
        {
            switch (ProposedAction)
            {
            case SetActionUIActions.FrontIcon:
                UIActionManager.SetSprite(IServerActionGUI, SpriteLocation);
                break;

            case SetActionUIActions.BackgroundIcon:
                UIActionManager.SetBackground(IServerActionGUI, SpriteLocation);
                break;

            case SetActionUIActions.StateChange:
                UIActionManager.Toggle(IServerActionGUI, showAlert);
                break;
            }
        }
    }
示例#4
0
 public static SetActionUI SetBackgroundSprite(GameObject recipient, IServerActionGUI iServerActionGUI,
                                               int FrontIconlocation)
 {
     return(_Send(recipient, iServerActionGUI, SetActionUIActions.BackgroundIcon, location: FrontIconlocation));
 }
示例#5
0
 public static SetActionUI SetAction(GameObject recipient, IServerActionGUI iServerActionGUI, bool _showAlert)
 {
     return(_Send(recipient, iServerActionGUI, SetActionUIActions.StateChange, _showAlert));
 }