示例#1
0
 private void ToggleState()
 {
     isOn = !isOn;
     spriteHandler.ChangeSprite(isOn ? (int)SpriteState.On : (int)SpriteState.Off);
     UIActionManager.SetSpriteSO(this, spriteHandler.GetCurrentSpriteSO());
     pickupable.RefreshUISlotImage();
 }
示例#2
0
    //syncvar hook invoked client side when the buckledTo changes
    private void SyncBuckledObjectNetId(uint oldBuckledTo, uint newBuckledTo)
    {
        //unsub if we are subbed
        if (IsBuckled)
        {
            var directionalObject = BuckledObject.GetComponent <Directional>();
            if (directionalObject != null)
            {
                directionalObject.OnDirectionChange.RemoveListener(OnBuckledObjectDirectionChange);
            }
        }

        if (PlayerManager.LocalPlayer == gameObject)
        {
            UIActionManager.ToggleLocal(this, newBuckledTo != NetId.Empty);
        }

        buckledObjectNetId = newBuckledTo;
        buckledObject      = NetworkUtils.FindObjectOrNull(buckledObjectNetId);

        //sub
        if (buckledObject != null)
        {
            var directionalObject = buckledObject.GetComponent <Directional>();
            if (directionalObject != null)
            {
                directionalObject.OnDirectionChange.AddListener(OnBuckledObjectDirectionChange);
            }
        }

        //ensure we are in sync with server
        playerScript?.PlayerSync?.RollbackPrediction();
    }
示例#3
0
 public void CallActionClient()
 {
     if (!PlayerManager.LocalPlayerScript.IsDeadOrGhost)
     {
         UIActionManager.SetSprite(this, (!isOn ? sprites[1] : sprites[0]));
     }
 }
 public void CallActionClient()
 {
     if (!PlayerManager.LocalPlayerScript.IsDeadOrGhost)
     {
         int index = isOn ? (int)SpriteState.On : (int)SpriteState.Off;
         UIActionManager.SetSprite(this, index);
     }
 }
        public override void Process(NetMessage msg)
        {
            IActionGUI action = null;

            if (msg.actionListID != 0)
            {
                //SO action singleton ID
                action = UIActionSOSingleton.Instance.FromID(msg.actionListID);
            }
            else if (msg.spellListIndex >= 0)
            {
                //SpellList singleton index
                var spellData = SpellList.Instance.FromIndex(msg.spellListIndex);

                if (UIActionManager.HasActionData(spellData, out action) == false)
                {
                    // no need to instantiate a spell if server asks to hide one anyway
                    if (msg.ProposedAction == UpdateType.StateChange && msg.showAlert == false)
                    {
                        return;
                    }

                    action = spellData.AddToPlayer(PlayerManager.LocalPlayerScript);
                }
            }
            else
            {
                // Action pre-placed on a networked object
                LoadNetworkObject(msg.NetObject);
                var actions = NetworkObject.GetComponentsInChildren(DeserializeType(msg.ComponentID));
                if ((actions.Length > msg.ComponentLocation))
                {
                    action = (actions[msg.ComponentLocation] as IActionGUI);
                }
            }

            if (action != null)
            {
                switch (msg.ProposedAction)
                {
                case UpdateType.FrontIcon:
                    UIActionManager.SetSprite(action, msg.SpriteLocation);
                    break;

                case UpdateType.BackgroundIcon:
                    UIActionManager.SetBackground(action, msg.SpriteLocation);
                    break;

                case UpdateType.StateChange:
                    UIActionManager.ToggleLocal(action, msg.showAlert);
                    break;

                case UpdateType.Cooldown:
                    UIActionManager.SetCooldownLocal(action, msg.cooldown);
                    break;
                }
            }
        }
示例#6
0
        private void DetermineAlertUI()
        {
            if (thisPlayerScript != PlayerManager.PlayerScript)
            {
                return;
            }

            UIActionManager.ToggleLocal(this, GameObjectReference != null);
        }
    public void OnInventoryMoveClient(ClientInventoryMove info)
    {
        var pna       = PlayerManager.LocalPlayerScript.playerNetworkActions;
        var showAlert = pna.GetActiveHandItem() == gameObject ||
                        pna.GetOffHandItem() == gameObject;

        foreach (var _IActionGUI in ControllingActions)
        {
            UIActionManager.ToggleLocal(_IActionGUI, showAlert);
        }
    }
示例#8
0
    public void OnInventoryMoveClient(ClientInventoryMove info)
    {
        var pna = PlayerManager.LocalPlayerScript.playerNetworkActions;

        if (info.ClientInventoryMoveType == ClientInventoryMoveType.Added
            & pna.GetActiveItemInSlot(NamedSlot.feet)?.gameObject == gameObject)
        {
            UIActionManager.Toggle(this, true);
            UIActionManager.SetSprite(this, (sprites[0]));
        }
        else if (info.ClientInventoryMoveType == ClientInventoryMoveType.Removed
                 & pna.GetActiveItemInSlot(NamedSlot.feet)?.gameObject != gameObject)
        {
            UIActionManager.Toggle(this, false);
        }
    }
示例#9
0
    private void DetermineAlertUI()
    {
        if (thisPlayerScript != PlayerManager.PlayerScript)
        {
            return;
        }

        if (GameObjectReference != null)
        {
            UIActionManager.ToggleLocal(this, true);
        }
        else
        {
            UIActionManager.ToggleLocal(this, false);
        }
    }
示例#10
0
 private void OnPlayerDeath()
 {
     if (isServer)
     {
         if (isOn)
         {
             ServerChangeState(player);
         }
         UIActionManager.Toggle(this, false);
         player.Script.playerHealth.OnDeathNotifyEvent -= OnPlayerDeath;
         player = null;
     }
     else
     {
         UIActionManager.Toggle(this, false);
     }
 }
示例#11
0
    // TODO: this should be merged into a new AlertUI action system once it's implemented
    // Client only method
    public void OnInventoryMoveClient(ClientInventoryMove info)
    {
        if (CustomNetworkManager.Instance._isServer && GameData.IsHeadlessServer)
        {
            return;
        }

        if (canClickPickup)
        {
            // Show the 'switch pickup mode' action button if this is in either of the players hands
            var pna       = PlayerManager.LocalPlayerScript.playerNetworkActions;
            var showAlert = pna.GetActiveHandItem() == gameObject ||
                            pna.GetOffHandItem() == gameObject;

            UIActionManager.ToggleLocal(this, showAlert);
        }
    }
    public void CallActionClient()
    {
        UIActionManager.SetSprite(this, (!isOn ? sprites[1] : sprites[0]));
        var hand = PlayerManager.LocalPlayerScript.playerNetworkActions;

        //if player has it on his feet
        if (hand.GetActiveItemInSlot(NamedSlot.feet) != null && hand.GetActiveItemInSlot(NamedSlot.feet) == gameObject)
        {
            if (!isOn)
            {
                ClientChangeSpeed(newSpeed);                //newspeed
            }
            else
            {
                ClientChangeSpeed(initialSpeed);                //old
            }
        }
    }
示例#13
0
    public void OnInventoryMoveClient(ClientInventoryMove info)
    {
        if (CustomNetworkManager.Instance._isServer && GameData.IsHeadlessServer)
        {
            return;
        }
        var pna = PlayerManager.LocalPlayerScript.playerNetworkActions;

        switch (info.ClientInventoryMoveType)
        {
        case ClientInventoryMoveType.Added when pna.GetActiveItemInSlot(NamedSlot.feet)?.gameObject == gameObject:
            UIActionManager.ToggleLocal(this, true);

            UIActionManager.SetSprite(this, (sprites[0]));
            break;

        case ClientInventoryMoveType.Removed when pna.GetActiveItemInSlot(NamedSlot.feet)?.gameObject != gameObject:
            UIActionManager.ToggleLocal(this, false);

            break;
        }
    }
示例#14
0
        public void OnInventoryMoveClient(ClientInventoryMove info)
        {
            if (!hasActionButton)
            {
                return;
            }

            bool shouldShowButton = pickupable.ItemSlot != null &&
                                    pickupable.ItemSlot.Player != null &&
                                    info.ClientInventoryMoveType == ClientInventoryMoveType.Added;

            if (!shouldShowButton)
            {
                UIActionManager.ToggleLocal(this, false);
                return;
            }

            // If the slot the item is a slot of the client's.
            if (pickupable.ItemSlot.LocalUISlot != null)
            {
                UIActionManager.ToggleLocal(this, true);
                UIActionManager.SetSpriteSO(this, spriteHandler.GetCurrentSpriteSO(), false);
            }
        }
示例#15
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;
            }
        }
    }
    // Client only method
    public void OnInventoryMoveClient(ClientInventoryMove info)
    {
        if (CustomNetworkManager.Instance._isServer && GameData.IsHeadlessServer)
        {
            return;
        }

        var hand = PlayerManager.LocalPlayerScript.playerNetworkActions;

        //when item is moved and player has it on his feet
        if (hand.GetActiveItemInSlot(NamedSlot.feet) != null && hand.GetActiveItemInSlot(NamedSlot.feet) == gameObject)
        {
            UIActionManager.Toggle(this, true);
            UIActionManager.SetSprite(this, (sprites[0]));
        }
        else
        {
            if (isOn)
            {
                ClientChangeSpeed(initialSpeed);                //old
            }
            UIActionManager.Toggle(this, false);
        }
    }
 public override void Init(Actor actor)
 {
     android       = actor as AliveAndroid;
     actionManager = FindObjectOfType <UIActionManager>();
     android.transform.LookAt(android.transform.position + Vector3.forward);
 }
示例#18
0
 public void ActivateAntagAction(bool state)
 {
     UIActionManager.ToggleLocal(this, state);
 }
示例#19
0
 void Awake()
 {
     instance = this;
     actionSelectionCanvas.SetActive(false);
     canWalk = true;
 }
示例#20
0
 public override void Init(Actor actor)
 {
     actionManager = FindObjectOfType <UIActionManager>();
 }
    public void OnPointerClick(PointerEventData eventData)
    {
        // Set didClick flag to true
        didClick = true;
        // Get the current Image on this inventory slot button
        Image thisSlot = GetComponent <Image>();
        // Get the instance of the UIActionManager
        UIActionManager actions = UIActionManager.instance;

        // Check if we're going to use an item and if we've selected an item from the inventory
        // to actually use.
        if (actions.canUse && assignedItem != null)
        {
            // Check the name of the item we are going to use and do the appropriate action
            // for that item.
            switch (assignedItem.name)
            {
            case "Whip":
                Cursor.SetCursor(whipCursor, Vector2.zero, CursorMode.Auto);
                InventoryUseItem.instance.currentItem = assignedItem;
                break;

            case "Kerosene Lamp":
                Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
                if (assignedItem.isOpen)
                {
                    InventoryUseItem.instance.currentItem = assignedItem;
                    wasUsed = true;
                }
                else
                {
                    UpdateSprites(assignedItem);

                    indianaJones.TextUpdate("I think I need to open it first.");
                    indianaJones.isTextEnabled = true;
                    wasUsed = false;
                }
                break;

            case "Spiral Design":
                Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
                InventoryUseItem.instance.currentItem = assignedItem;
                wasUsed = true;
                break;

            default:
                Debug.LogError("Something in switching the cursor went wrong!" + assignedItem);
                break;
            }

            // Set the assignedItem to null as we've either used it or put it back into the inventory
            //assignedItem = null;

            // Set the itemDefaultSprite and itemHighlightedSprite to null, as
            // we no longer have an item.
            //itemDefaultSprite = null;
            //itemHighlightedSprite = null;

            if (wasUsed)
            {
                UpdateSprites(null);
            }
        }
        else if (actions.canLookAt)
        {
            if (assignedItem != null)
            {
                actions.DoAction_LookAt(assignedItem, didClick);
            }
            else
            {
                if (InventoryUseItem.instance.currentItem != null)
                {
                    if (!assignedItem.isOpen)
                    {
                        InventoryUIManager.instance.OnInventoryUpdate(InventoryUseItem.instance.currentItem);
                        Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
                    }
                    else
                    {
                        UpdateSprites(assignedItem);
                    }
                }
                else
                {
                    indianaJones.TextUpdate("There's nothing to look at!");
                    indianaJones.isTextEnabled = true;
                }
            }
        }
        else if (actions.canOpen)
        {
            if (assignedItem != null)
            {
                actions.DoAction_Open(assignedItem);
                UpdateSprites(assignedItem);
            }
        }
        else if (actions.canClose)
        {
            if (assignedItem != null)
            {
                actions.DoAction_Close(assignedItem);
                UpdateSprites(assignedItem);
            }
        }
    }
示例#22
0
 public void CallActionClient()
 {
     UIActionManager.SetSprite(this, (!isOn ? sprites[1] : sprites[0]));
 }
示例#23
0
 void Start()
 {
     // Set the variable to the instance
     action = UIActionManager.instance;
 }
示例#24
0
 public override void Init(Actor actor)
 {
     android       = actor as AliveAndroid;
     actionManager = FindObjectOfType <UIActionManager>();
     input         = UGL.inputManager;
 }
示例#25
0
 public override void OnStartServer()
 {
     // TODO Instead, consider listening for client's OnPlayerSpawned and then request server to run stuff.
     StartCoroutine(DelayInitialisation());
     UIActionManager.Show(this);
 }
 public override void Init(Actor actor)
 {
     this.android  = actor as AliveAndroid;
     actionManager = FindObjectOfType <UIActionManager>();
 }
示例#27
0
 protected virtual void ToggleLight()
 {
     lightControl.Toggle(!lightControl.IsOn);
     spriteHandler.ChangeSprite(SpriteIndex);
     UIActionManager.SetSpriteSO(this, spriteHandler.GetCurrentSpriteSO());
 }