コード例 #1
0
        protected FileSystemEntityViewModel()
        {
            IsExpanded = new NotifyingProperty <bool>(
                x => InteractCommand?.Execute(null)
                );

            ErrorMessage             = new NotifyingProperty <string>(
                x => Focusable.Value = string.IsNullOrEmpty(x)
                );

            DragItem = new DragAndDropHandler(
                () => string.IsNullOrEmpty(ErrorMessage.Value),
                () => new DataObject(DataFormats.FileDrop, new string[] { EntityPath.Value })
                );

            FavoriteCommand = new RelayCommand(
                x => ArgsAndSettings.FavoritedLocations.Add(EntityPath.Value),
                x => !ArgsAndSettings.FavoritedLocations.Contains(EntityPath.Value)
                );

            UnfavoriteCommand = new RelayCommand(
                x => ArgsAndSettings.FavoritedLocations.Remove(EntityPath.Value),
                x => ArgsAndSettings.FavoritedLocations.Contains(EntityPath.Value)
                );
        }
コード例 #2
0
    private static Node CreateInteractionBehavior(Dorf d, IInteractable i)
    {
        Condition findWork = new Condition(() => {
            //TODO: what check here? Maybe an action to get a work-place?
            return false;
        });

        BehaviorTrees.Action goToWork = new BehaviorTrees.Action(() => {
            //TODO: replace vector param with location of workplace!
            var mc = new MoveCommand(d,new Vector3(),WALKSPEED);
            if (mc.isAllowed()) {
                mc.execute();
                return Node.Status.RUNNING;
            } else {
                return Node.Status.FAIL;
            }
        });

        BehaviorTrees.Action work = new BehaviorTrees.Action(() => {
            //TODO: replace null value with some kind of interactable variable from d.
            var ic = new InteractCommand(d,null);
            if (ic.isAllowed()) {
                ic.execute();
                return Node.Status.RUNNING;
            } else {
                return Node.Status.FAIL;
            }
        });

        SequenceSelector root = new SequenceSelector(findWork,goToWork,work);
        return root;
    }
コード例 #3
0
        public override Boolean CanDoAction(Command p_command)
        {
            InteractCommand interactCommand = (InteractCommand)p_command;
            Position        position        = Party.Position;
            GridSlot        slot            = Grid.GetSlot(position);
            Boolean         flag            = interactCommand.Target != null;

            flag |= (Party.SelectedInteractiveObject != null);
            flag |= (slot.GetPassiveInteractiveObjects(Party.Direction, Party.HasSpotSecrets(), Party.HasClairvoyance(), false).Count > 0);
            return(flag | slot.GetPassiveInteractiveObjects(EDirection.CENTER, Party.HasSpotSecrets(), Party.HasClairvoyance(), false).Count > 0);
        }
コード例 #4
0
    // Start is called before the first frame update
    void Start()
    {
        defaultCommands = new ICommand[4];

        defaultCommands[0] = new UseKnifeCommand();
        defaultCommands[1] = new ReloadCommand();
        defaultCommands[2] = new LootCommand();
        defaultCommands[3] = new InteractCommand();

        qCommand = defaultCommands[0]; // use knife
        rCommand = defaultCommands[1]; // reload
        xCommand = defaultCommands[2]; // loot
        kCommand = defaultCommands[3]; // interact
    }
コード例 #5
0
ファイル: GameManager.cs プロジェクト: innocence-ze/D203G8
 void InitInputManager()
 {
     ioMgr    = GetComponent <InputManager>();
     jump     = new JumpCommand(pc);
     stopJump = new StopJumpCommand(pc);
     dash     = new DashCommand(pc);
     left     = new MoveLeftCommand(pc);
     right    = new MoveRightCommand(pc);
     stopHor  = new StopMoveHorCommand(pc);
     up       = new MoveUpCommand(pc);
     down     = new MoveDownCommand(pc);
     stopVer  = new StopMoveVerCommand(pc);
     attack   = new AttackCommand(pc);
     interact = new InteractCommand(pc);
 }
コード例 #6
0
        public override void DoAction(Command p_command)
        {
            InteractCommand interactCommand = (InteractCommand)p_command;

            if (interactCommand.Target != null)
            {
                if (interactCommand.Target.Type == EObjectType.COMMAND_CONTAINER || (interactCommand.Target.Type == EObjectType.DOOR && interactCommand.Target.State == EInteractiveObjectState.DOOR_OPEN))
                {
                    return;
                }
                LegacyLogic.Instance.UpdateManager.InteractionsActor.AddObject(interactCommand.Target);
            }
            else if (Party.SelectedInteractiveObject != null)
            {
                if (Party.SelectedInteractiveObject.Type == EObjectType.COMMAND_CONTAINER || (Party.SelectedInteractiveObject.Type == EObjectType.DOOR && Party.SelectedInteractiveObject.State == EInteractiveObjectState.DOOR_OPEN))
                {
                    return;
                }
                LegacyLogic.Instance.UpdateManager.InteractionsActor.AddObject(Party.SelectedInteractiveObject);
            }
            else
            {
                Position position = Party.Position;
                GridSlot slot     = Grid.GetSlot(position);
                List <InteractiveObject> passiveInteractiveObjects = slot.GetPassiveInteractiveObjects(Party.Direction, Party.HasSpotSecrets(), Party.HasClairvoyance(), false);
                passiveInteractiveObjects.AddRange(slot.GetPassiveInteractiveObjects(EDirection.CENTER, Party.HasSpotSecrets(), Party.HasClairvoyance(), false));
                if (passiveInteractiveObjects.Count > 0)
                {
                    for (Int32 i = passiveInteractiveObjects.Count - 1; i >= 0; i--)
                    {
                        if (passiveInteractiveObjects[i].Type == EObjectType.COMMAND_CONTAINER)
                        {
                            passiveInteractiveObjects.RemoveAt(i);
                        }
                    }
                    for (Int32 j = passiveInteractiveObjects.Count - 1; j >= 0; j--)
                    {
                        if (passiveInteractiveObjects[j].Type == EObjectType.DOOR && passiveInteractiveObjects[j].State == EInteractiveObjectState.DOOR_OPEN)
                        {
                            passiveInteractiveObjects.RemoveAt(j);
                        }
                    }
                    LegacyLogic.Instance.EventManager.InvokeEvent(null, EEventType.PASSIVE_INTERACTIVE_OBJECT_FOUND, new InteractiveObjectListEventArgs(passiveInteractiveObjects));
                    LegacyLogic.Instance.UpdateManager.InteractionsActor.AddObject(passiveInteractiveObjects);
                }
            }
        }
コード例 #7
0
        private void Awake()
        {
            Application.targetFrameRate = 30;
            jumpCommand          = new JumpCommand();
            moveLeftCommand      = new MoveLeftCommand();
            moveRightCommand     = new MoveRightCommand();
            notMoveCommand       = new NotMoveCommand();
            doNothingCommand     = new DoNothingCommand();
            transgressionCommand = new TransgressionCommand();
            pauseCommand         = new PauseCommand();
            interactCommand      = new InteractCommand();

            commands = new Dictionary <string, Command>
            {
                { "Jump", jumpCommand },
                { "Teleport", transgressionCommand },
                { "Use", interactCommand }
            };

            commandsWithoutPlayer = new Dictionary <string, Command>
            {
                { "Exit", pauseCommand }
            };
        }
コード例 #8
0
        public static void InitializeControllersForGameplay(Game1 game, KeyboardController keyboard, GamepadController gamepad)
        {
            keyboard.ClearDictionary();
            gamepad.ClearDictionary();
            //Background sound
            ICommand mutecommand = new MuteCommand(Stage.sound);

            keyboard.Add((int)Keys.M, mutecommand);
            //Add the Reset command to the r
            ICommand resetcommand = new ResetCommand();

            keyboard.Add((int)Keys.R, resetcommand);
            gamepad.Add((int)Buttons.Back, resetcommand);
            //Add the Exit Command to the controllers
            ICommand exitcommand = new ExitCommand(game);

            keyboard.Add((int)Keys.Q, exitcommand);
            gamepad.Add((int)Buttons.Start, exitcommand);
            //add the left command
            ICommand leftcommand = new LeftCommand(Stage.mario);

            keyboard.Add((int)Keys.A, leftcommand);
            keyboard.Add((int)Keys.Left, leftcommand);
            gamepad.Add((int)Buttons.DPadLeft, leftcommand);
            //add the right commmand
            ICommand rightcommand = new RightCommand(Stage.mario);

            keyboard.Add((int)Keys.D, rightcommand);
            keyboard.Add((int)Keys.Right, rightcommand);
            gamepad.Add((int)Buttons.DPadRight, rightcommand);
            //Add the srpint command
            ICommand sprintcommand = new SprintCommand(Stage.mario);

            keyboard.Add((int)Keys.LeftShift, sprintcommand);
            keyboard.Add((int)Keys.RightShift, sprintcommand);
            //add the down command
            ICommand downcommand = new DownCommand(Stage.mario);

            keyboard.Add((int)Keys.S, downcommand);
            keyboard.Add((int)Keys.Down, downcommand);
            gamepad.Add((int)Buttons.DPadDown, downcommand);
            //add the up command
            ICommand upcommand = new UpCommand(Stage.mario);

            keyboard.Add((int)Keys.W, upcommand);
            keyboard.Add((int)Keys.Up, upcommand);
            gamepad.Add((int)Buttons.DPadUp, upcommand);
            //add fireflower command
            ICommand firecommand = new FireMarioCommand(Stage.mario);

            keyboard.Add((int)Keys.I, firecommand);
            //add super command
            ICommand supercommand = new SuperCommand(Stage.mario);

            keyboard.Add((int)Keys.U, supercommand);
            //add normal mario command
            ICommand normalcommand = new NormalCommand(Stage.mario);

            keyboard.Add((int)Keys.Y, normalcommand);
            //add take damage command
            ICommand damagecommand = new DamageCommand(Stage.mario);

            keyboard.Add((int)Keys.O, damagecommand);
            //add star power command
            ICommand starcommand = new StarCommand(Stage.mario);

            keyboard.Add((int)Keys.L, starcommand);
            //add the fireball command with space
            ICommand fireballcommand = new MakeFireBall(Stage.mario);

            keyboard.Add((int)Keys.Space, fireballcommand);
            //add the Pause hud command with N
            ICommand pausehudcommand = new PauseCommand();

            keyboard.Add((int)Keys.P, pausehudcommand);
            ICommand interact = new InteractCommand();

            keyboard.Add((int)Keys.V, interact);
            gamepad.Add((int)Buttons.RightTrigger, interact);
            //add hold command E, no current mapping on gamepad
            ICommand holdcommand = new HoldingCommand(Stage.mario);

            keyboard.Add((int)Keys.E, holdcommand);


            /*
             * Add release commands. These are mainly for mario movement.
             */
            ICommand rightR = new ReleaseRightCommand(Stage.mario);

            keyboard.AddRelease((int)Keys.D, rightR);
            keyboard.AddRelease((int)Keys.Right, rightR);


            ICommand leftR = new ReleaseLeftCommand(Stage.mario);

            keyboard.AddRelease((int)Keys.A, leftR);
            keyboard.AddRelease((int)Keys.Left, leftR);

            ICommand downR = new ReleaseDownCommand(Stage.mario);

            keyboard.AddRelease((int)Keys.S, downR);
            keyboard.AddRelease((int)Keys.Down, downR);


            ICommand upR = new ReleaseUpCommand(Stage.mario);

            keyboard.AddRelease((int)Keys.W, upR);
            keyboard.AddRelease((int)Keys.Up, upR);

            ICommand sprintR = new ReleaseSprintCommand(Stage.mario);

            keyboard.AddRelease((int)Keys.LeftShift, sprintR);
            keyboard.AddRelease((int)Keys.RightShift, sprintR);

            ICommand holdR = new ReleaseHoldingCommand(Stage.mario);

            keyboard.AddRelease((int)Keys.E, holdR);
        }
コード例 #9
0
    // Update is called once per frame
    void Update()
    {
        List <NetworkCommand> cmds = Network.getPendingCommands();

        if (cmds != null)
        {
            foreach (NetworkCommand cmd in cmds)
            {
                /*** IN-GAME ACTIONS ***/
                if (cmd is MoveCommand)
                {
                    MoveCommand move  = (MoveCommand)cmd;
                    Pos         start = Network.getPlayer(move.clientID).grid_pos;
                    Pos         end   = move.end;
                    Debug.Log("Move received! From " + start + " to " + end);

                    mapManager.move(start, end);
                }
                if (cmd is AttackCommand)
                {
                    AttackCommand attack = (AttackCommand)cmd;
                    Pos           start  = Network.getPlayer(attack.clientID).grid_pos;
                    Pos           end    = attack.end;
                    Debug.Log("Attack received! From " + start + " to " + end + " action No: " + attack.actionNo);

                    mapManager.attack(start, end, attack.actionNo);
                }
                if (cmd is WaitCommand)
                {
                    WaitCommand wait = (WaitCommand)cmd;
                    Debug.Log("Wait received! From client#" + wait.clientID);

                    Client waitingClient = Network.getPeer(wait.clientID);
                    waitingClient.playerObject.wait();
                }
                if (cmd is InteractCommand)
                {
                    InteractCommand interact = (InteractCommand)cmd;
                    Pos             start    = Network.getPlayer(interact.clientID).grid_pos;
                    Pos             end      = interact.end;
                    Debug.Log("Interact received! From " + start + " to " + end);

                    mapManager.interact(start, end);
                }
                if (cmd is UseItemCommand)
                {
                    UseItemCommand item      = (UseItemCommand)cmd;
                    Player         player    = Network.getPlayer(item.clientID);
                    Item           itemToUse = player.inventory.GetItemFromSlot(item.slotIndex);
                    player.inventory.DecrementItemAtSlot(item.slotIndex);
                    InventoryManager.UseItem(itemToUse, player);
                    Debug.Log("Use Item received! From client#" + item.clientID + " for item in slot #" + item.slotIndex);
                }
                /*** LOBBY ACTIONS ***/
                if (cmd is ReadyCommand)
                {
                    ReadyCommand ready = (ReadyCommand)cmd;
                    Debug.Log("Received READY");

                    Client client = Network.getPeer(ready.clientID);
                    if (client == null)
                    {
                        Network.setPeer(ready.clientID);
                        client = Network.getPeer(ready.clientID);
                    }
                    client.ready = !client.ready;
                }
                if (cmd is NicknameCommand)
                {
                    NicknameCommand nickname = (NicknameCommand)cmd;
                    Debug.Log("Received nickname: " + nickname.nickname);

                    Client client = Network.getPeer(nickname.clientID);
                    if (client == null)
                    {
                        Network.setPeer(nickname.clientID);
                        client = Network.getPeer(nickname.clientID);
                    }
                    client.nickname = nickname.nickname;
                }
                if (cmd is ClassnameCommand)
                {
                    ClassnameCommand classname = (ClassnameCommand)cmd;
                    Debug.Log("Received classname: " + classname.classname);

                    Client client = Network.getPeer(classname.clientID);
                    if (client == null)
                    {
                        Network.setPeer(classname.clientID);
                        client = Network.getPeer(classname.clientID);
                    }
                    client.classname = classname.classname;
                }
                if (cmd is UpdateClientInfoCommand)                   // called when a new player joins and needs to be synchronized
                {
                    UpdateClientInfoCommand update = (UpdateClientInfoCommand)cmd;
                    Debug.Log("Received update from client#" + update.clientID);

                    Client client = Network.getPeer(update.clientID);
                    if (client == null)
                    {
                        Network.setPeer(update.clientID);
                        client = Network.getPeer(update.clientID);
                    }
                    client.nickname  = update.nickname;
                    client.classname = update.classname;
                    client.ready     = update.ready;
                }
                if (cmd is SetSeedCommand)
                {
                    SetSeedCommand seed = (SetSeedCommand)cmd;
                    Debug.Log("Received seed!");

                    Settings.MasterSeed = seed.seed;
                }
                /*** NETWORK ACTIONS ***/
                if (cmd is JoinCommand)
                {
                    JoinCommand _join = (JoinCommand)cmd;                      // to avoid conflict with 'join' keyword
                    if (clientID == 0)
                    {
                        clientID = _join.clientID;
                        Debug.Log("Joined game! Client ID #" + clientID + " assigned!");
                    }
                    else
                    {
                        Debug.Log("New player with client ID #" + _join.clientID + " joined!");
                        Network.submitCommand(new UpdateClientInfoCommand(Network.getPeer(clientID)));
                        if (clientID == 1)
                        {
                            Network.submitCommand(new SetSeedCommand(Settings.MasterSeed));
                        }
                    }
                    Network.setPeer(_join.clientID);
                }
                if (cmd is StartCommand)
                {
                    StartCommand start = (StartCommand)cmd;
                    Debug.Log("Received START");
                    if (SceneManager.GetActiveScene().name == "NewMenu")                       // only loads new scene if we're in the lobby
                    {
                        SceneManager.LoadScene("Procedural");
                        foreach (Client client in Network.getPeers())
                        {
                            client.ready = false;
                        }
                    }
                    else
                    {
                        GameManager.NextLevel();
                    }
                }
                if (cmd is EndCommand)
                {
                    EndCommand end = (EndCommand)cmd;
                    Debug.Log("Received END");
                }
                if (cmd is DisconnectCommand)
                {
                    DisconnectCommand disconnect = (DisconnectCommand)cmd;
                    Debug.Log("Received DISCONNECT from client #" + disconnect.clientID);
                    Network.removePeer(disconnect.clientID);

                    if (clientID >= disconnect.clientID)
                    {
                        clientID--;
                        Debug.Log("Changed client ID to " + clientID);
                    }
                }
            }
        }
        if (!Network.connected())
        {
            clientID = 0;
        }
    }