Esempio n. 1
0
        public static void HandleSetActionButton(ref PacketReader packet, ref WorldClass session)
        {
            var pChar = session.Character;

            byte[] actionMask  = { 5, 2, 6, 7, 1, 4, 0, 3 };
            byte[] actionBytes = { 4, 3, 2, 0, 5, 7, 6, 1 };

            var slotId = packet.ReadByte();

            BitUnpack actionUnpacker = new BitUnpack(packet);

            var actionId = actionUnpacker.GetPackedValue(actionMask, actionBytes);

            if (actionId == 0)
            {
                var action = pChar.ActionButtons.Where(button => button.SlotId == slotId && button.SpecGroup == pChar.ActiveSpecGroup).Select(button => button).First();
                ActionMgr.RemoveActionButton(pChar, action, true);
                Log.Message(LogType.DEBUG, "Character (Guid: {0}) removed action button {1} from slot {2}.", pChar.Guid, actionId, slotId);
                return;
            }

            var newAction = new ActionButton
            {
                Action    = actionId,
                SlotId    = slotId,
                SpecGroup = pChar.ActiveSpecGroup
            };

            ActionMgr.AddActionButton(pChar, newAction, true);
            Log.Message(LogType.DEBUG, "Character (Guid: {0}) added action button {1} to slot {2}.", pChar.Guid, actionId, slotId);
        }
Esempio n. 2
0
    public void AddListener(string key, Action <object[]> callback)
    {
        if (!_stringReceivers.ContainsKey(key))
        {
            _stringReceivers[key] = new ActionMgr <object[]>();
        }

        _stringReceivers[key].Add(callback);
    }
Esempio n. 3
0
        public static void HandleUpdateActionButtons(ref WorldClass session)
        {
            var pChar = session.Character;

            PacketWriter updateActionButtons = new PacketWriter(ServerMessage.UpdateActionButtons);
            BitPack      BitPack             = new BitPack(updateActionButtons);

            const int buttonCount = 132;
            var       buttons     = new byte[buttonCount][];

            byte[] buttonMask  = { 7, 2, 6, 5, 0, 3, 4, 1 };
            byte[] buttonBytes = { 7, 1, 4, 0, 2, 5, 3, 6 };

            var actions = ActionMgr.GetActionButtons(pChar, pChar.ActiveSpecGroup);

            for (int i = 0; i < buttonCount; i++)
            {
                if (actions.Any(action => action.SlotId == i))
                {
                    buttons[i] = BitConverter.GetBytes((ulong)actions.Where(action => action.SlotId == i).Select(action => action.Action).First());
                }
                else
                {
                    buttons[i] = new byte[8];
                }
            }

            for (int i = 0; i < 16; i++)
            {
                for (int j = 0; j < buttonCount; j++)
                {
                    if (i < 8)
                    {
                        BitPack.Write(buttons[j][buttonMask[i]]);
                    }
                    else if (i < 16)
                    {
                        BitPack.Flush();

                        if (buttons[j][buttonBytes[i - 8]] != 0)
                        {
                            updateActionButtons.WriteUInt8((byte)(buttons[j][buttonBytes[i - 8]] ^ 1));
                        }
                    }
                }
            }

            // Packet Type (NYI)
            // 0 - Initial packet on Login (no verification) / 1 - Verify spells on switch (Spec change) / 2 - Clear Action Buttons (Spec change)
            updateActionButtons.WriteInt8(0);

            session.Send(ref updateActionButtons);
        }
Esempio n. 4
0
        public override StateMachine Update(GridIndex?click)
        {
            var selectionPiece = ActionMgr.SelectionPiece;

            ActionMgr.selection = null;

            if (click.HasValue)
            {
                var target = ActionMgr.board[click.Value];
                if (target != null)
                {
                    ActionMgr.AddAttack(selectionPiece, target);
                }
                else
                {
                    ActionMgr.AddMove(selectionPiece, click.Value);
                }
            }

            return(new UnselectedState(ActionMgr));
        }
Esempio n. 5
0
    // Use this for initialization
    protected virtual void Start()
    {
        _actionMgr  = new ActionMgr();
        _commandMgr = new CommandMgr();
        _buffMgr    = new BuffMgr(this);

        //// Load Mecha Data
        //UnityFactory.factory.LoadDragonBonesData("DB/hero/hr021_ske");
        //UnityFactory.factory.LoadTextureAtlasData("DB/hero/hr021_tex");

        //// Build Mecha Armature
        //ArmatureComp = UnityFactory.factory.BuildArmatureComponent("Hero");
        ////
        //ArmatureComp.CloseCombineMeshs();
        //ArmatureComp.sortingOrder = 100;
        //ArmatureComp.sortingLayerName = "Active";
        //ArmatureComp.transform.parent = transform;
        //ArmatureComp.transform.position = Vector3.zero;

        _bornPosition = transform.position;
        InitArmature();
        _roleInfo.addListener(EventBase.CHANGE, OnInfoChanged);
    }
Esempio n. 6
0
 public void Refresh(ActionMgr mgr)
 {
     _mgr = mgr;
 }
Esempio n. 7
0
    void OnSelectionChange()
    {
        if (_selectedNode != null && Selection.activeObject == _selectedNode.Data)
            return;

        _gameobject = Selection.activeGameObject;
        var script = _gameobject.GetComponent<ScratchScript>();
        if (script != null)
        {
            _mgr = script.mgr;
        }
        else
        {
            _mgr = null;
        }
    }
Esempio n. 8
0
    private void initMenu()
    {
        _menu = new GenericMenu();

        foreach (BaseAction action in _allActions)
        {
            BaseAction curr = action;
            _menu.AddItem(new GUIContent(curr.ToString()), false, () =>
            {
                newAction(curr.Id());
            });
        }

        _menuAddScript = new GenericMenu();
        _menuAddScript.AddItem(new GUIContent("Add Scratch Script"), false, () =>
        {
            var script = _gameobject.AddComponent<ScratchScript>();
            _mgr = script.mgr;
        });
    }