static void BuildMenu(IAction action, ActionValidity validity, GenericMenu.MenuFunction executeFunction, List <MenuActionItem> menuItems, MenuFilter filter, bool isChecked = false)
        {
            var menuAttribute = action.GetType().GetCustomAttribute <MenuEntryAttribute>(false);

            if (menuAttribute == null || filter.ShouldFilterOut(menuAttribute))
            {
                return;
            }

            if (validity == ActionValidity.NotApplicable)
            {
                return;
            }

            var menuActionItem = new MenuActionItem
            {
                state          = validity,
                entryName      = action.GetMenuEntryName(),
                priority       = menuAttribute.priority,
                category       = menuAttribute.subMenuPath,
                isActiveInMode = action.IsActionActiveInMode(TimelineWindow.instance.currentMode.mode),
                shortCut       = action.GetShortcut(),
                callback       = executeFunction,
                isChecked      = action.IsChecked()
            };

            menuItems.Add(menuActionItem);
        }
예제 #2
0
    public override void NET_Move(Guid player, Point newPos, ActionValidity mv)
    {
        base.NET_Move(player, newPos, mv);

        bool teleported = mv.Has(ActionValidity.REMOTE);

        if (mv.Has(ActionValidity.NEW))
        {
            AddPlayer(base.GetPlayerInfo(player));
        }

        GameObject obj = loots[newPos];

        if (obj != null)
        {
            GameObject.Destroy(obj);
            loots[newPos] = null;
        }

        GameObject movedPlayer = playerAvatars.GetValue(player);

        if (teleported && !mv.Has(ActionValidity.NEW))
        {
            NewTeleportAnimation(movedPlayer.transform.position, movedPlayer.renderer.material.color);
        }

        movedPlayer.transform.position = minecraft.GetPositionAtGrid(Position, newPos);

        if (teleported)
        {
            movedPlayer.transform.localScale = Vector3.one * .1f;
        }

        updateCamera(player, movedPlayer);
    }
예제 #3
0
        static PlayerMove PlayerRandomMove(World world, Guid player, Aggregator all)
        {
            if (!world.HasPlayer(player))
            {
                return(null);
            }

            Point currPos = world.GetPlayerPosition(player);

            Point[] moves =
            {
                new Point(-1,  0),
                new Point(1,   0),
                new Point(0,   1),
                new Point(0,  -1),
                new Point(-1,  1),
                new Point(1,  -1),
                new Point(1,   1),
                new Point(-1, -1)
            };

            Point newPosition = currPos + moves[rand.Next(0, moves.Length)];

            ActionValidity mv = world.CheckValidMove(player, newPosition);

            if (mv == ActionValidity.BOUNDARY)
            {
                RealmMove rm = WorldTools.BoundaryMove(newPosition, world.Position);
                World     w  = all.myClient.worlds.TryGetWorld(rm.newWorld);

                if (w == null)
                {
                    return(null);
                }

                if (!w[rm.newPosition].IsMoveable())
                {
                    return(null);
                }
            }

            if (mv == ActionValidity.VALID || mv == ActionValidity.BOUNDARY)
            {
                return new PlayerMove()
                       {
                           mv = mv, newPos = newPosition
                       }
            }
            ;
            else
            {
                return(null);
            }
        }
예제 #4
0
    void ProcessMovement()
    {
        Point p = Point.Zero;

        foreach (KeyCode k in keyDir.Keys)
        {
            if (Input.GetKeyDown(k))
            {
                if (keyTrack.ContainsKey(k))
                {
                    keyTrack.Remove(k);
                }

                keyTrack.Add(k, 0);
                p += keyDir[k];
            }

            if (Input.GetKeyUp(k))
            {
                if (keyTrack.ContainsKey(k))
                {
                    keyTrack.Remove(k);
                }
            }
        }

        foreach (KeyCode k in keyTrack.Keys.ToArray())
        {
            keyTrack[k] += Time.deltaTime;
            if (keyTrack[k] >= .2f)
            {
                keyTrack[k] = 0;
                p          += keyDir[k];
            }
        }

        bool teleport = Input.GetMouseButtonDown(0);
        bool move     = (p != Point.Zero);

        if (!(move || teleport))
        {
            return;
        }

        PlayerAgent pa = myAgent;
        PlayerData  pd = myData;

        if (pa == null || pd == null || !pd.IsConnected)
        {
            return;
        }

        World w = all.myClient.worlds.TryGetWorld(pd.WorldPosition);

        if (w == null)
        {
            return;
        }
        if (!w.HasPlayer(me))
        {
            return;
        }

        if (move)
        {
            Point oldPos = w.GetPlayerPosition(me);
            Point newPos = oldPos + p;

            ActionValidity mv = w.CheckValidMove(me, newPos);

            if (mv == ActionValidity.VALID || mv == ActionValidity.BOUNDARY)
            {
                pa.Move(w.Info, newPos, mv);
            }
        }
        else if (teleport)
        {
            Point pos = RayCast(w.Position);

            //Log.LogWriteLine("Teleporting to {0}", pos);
            pa.Move(w.Info, pos, ActionValidity.REMOTE);
            //pa.Move(all.myClient.gameInfo.GetWorldByPos(Point.Zero), pos, ActionValidity.REMOTE);
        }
    }
예제 #5
0
 public void Move(WorldInfo worldInfo, Point newPos, ActionValidity mv)
 {
     MessageWorld(worldInfo, MessageType.MOVE_REQUEST, newPos, mv);
 }