コード例 #1
0
ファイル: Player.cs プロジェクト: HassakuTb/IkkiuchiV2
        public IList <IAction> GetActualActions(int countOfMoment, Controller controller)
        {
            IList <IAction> actual = new List <IAction>();

            for (int i = 0; i < countOfMoment; ++i)
            {
                //  攻撃がプロットされているとき
                if (Plots.IsActionPloted(i))
                {
                    actual.Add(Plots.ActionPloted(i).Action);
                }
                //  移動がプロットされているとき
                else if (Plots.IsMovePloted(i))
                {
                    Move act = ScriptableObject.Instantiate(Resources.Load <Move>("ScriptableObjects/Actions/Move"));
                    act.Controller = controller;
                    act.Direction  = Plots.MovePloted(i).MoveDirection;
                    actual.Add(act);
                }
                //  移動と攻撃の両方がプロットされていないとき
                else
                {
                    NoAction act = ScriptableObject.Instantiate(Resources.Load <NoAction>("ScriptableObjects/Actions/NoAction"));
                    act.Controller = controller;
                    actual.Add(act);
                }
            }

            return(actual);
        }
コード例 #2
0
        public void GoToWaitingForNewClient()
        {
            Person person = new Person();

            MenuShift();
            _mainMenu.ShowWaitingProcess();
            person = JsonParser.GetRandomPerson();

            if (person.haveTicket)
            {
                MenuShift();
                _mainMenu.ShowWelcomeMenu(person);
                Console.WriteLine("Ok! You have a ticket!\nPlease go to passport control.");
                Thread.Sleep(3000);
                GoToPassportControl(person);
            }
            else
            {
                MenuShift();
                _mainMenu.ShowWelcomeMenu(person);
                YesNoTool tool      = _mainMenu.ShowBuyingTicketMenu;
                YesAction yesAction = delegate { Console.WriteLine("\nOK! Now you have a ticket! Please go to passport control."); };
                NoAction  noAction  = delegate { Console.WriteLine("\nSorry you can't uses our services without any ticket. Please come back latter.\nGood Luck to you!"); };

                if (EnterEscapeMenu(tool, yesAction, noAction, ConstantsValues.ErrorMessage))
                {
                    GoToPassportControl(person);
                }
            }
        }
コード例 #3
0
        public static IAction GetAction(RoverAction rAction)
        {
            IAction action;

            switch (rAction)
            {
            case RoverAction.L:
                action = new TurnLeftAction();
                break;

            case RoverAction.R:
                action = new TurnRightAction();
                break;

            case RoverAction.M:
                action = new MoveForwardAction();
                break;

            default:
                action = new NoAction();
                break;
            }

            return(action);
        }
コード例 #4
0
        public bool EnterEscapeMenu(YesNoTool tool, YesAction yes, NoAction no, string error)
        {
            ConsoleKey key = ConsoleKey.F19;

            while (key != ConsoleKey.Enter && key != ConsoleKey.Escape)
            {
                tool.Invoke();
                _mainMenu.ShowEnterEscMenu();
                Console.WriteLine(_errorMessage);
                key = Console.ReadKey().Key;
                if (key == ConsoleKey.Enter)
                {
                    yes.Invoke();
                    Thread.Sleep(3000);
                    return(true);
                }

                if (key == ConsoleKey.Escape)
                {
                    no.Invoke();
                    Thread.Sleep(3000);
                    GoBack();
                }
                _errorMessage = error;
                MenuShift();
            }
            _errorMessage = "";
            return(false);
        }
コード例 #5
0
        public void GoToLuggageControl(Person person)
        {
            #region LuggageCheckSuggestion

            YesNoTool tool = delegate
            {
                Console.WriteLine($"Dear {person.name} {person.surname} please, let us check your luggage.");
            };

            YesAction yseAction = delegate
            {
                Console.WriteLine("Ok! wait for a few minutes, we start to check your luggage.");
            };

            NoAction noAction = delegate
            {
                Console.WriteLine(
                    $"Sorry dear {person.name} {person.surname} you can't use our services without this stage of luggage control." +
                    $"\nPlease come back later");
            };

            if (!EnterEscapeMenu(tool, yseAction, noAction, ConstantsValues.ErrorMessage))
            {
                GoBack();
                return;
            }

            #endregion

            if (person.baggageWeight > ConstantsValues.AcceptedWeight)
            {
                tool      = _mainMenu.ShowOverWeightNotification;
                yseAction = delegate
                {
                    Console.WriteLine("Ok, all right. Now we will check your luggage for a prohibited items");
                };

                if (!EnterEscapeMenu(tool, yseAction, noAction, ConstantsValues.ErrorMessage))
                {
                    GoBack();
                    return;
                }
            }

            if (person.prohibitedItems)
            {
                _mainMenu.ShowProhibitedItemsEnables(person);
                GoBack();
                return;
            }
            else
            {
            }

            _mainMenu.ShowSuccessLuggageControlResult();
        }
コード例 #6
0
    private void SendPendingAction()
    {
        IAction action = null;

        if (actionsToSend.Count > 0)
        {
            action = actionsToSend.Dequeue();
        }

        if (action == null)
        {
            action = new NoAction();
        }
        pendingActions.AddAction(action, this.virtualClient.ID, LockStepTurnID, LockStepTurnID);
        SendActionToOtherPlayers(LockStepTurnID, this.virtualClient.ID, action);
    }
コード例 #7
0
ファイル: ClientHUD.cs プロジェクト: nashnie/LockstepByUNet
    private void SendPendingAction()
    {
        Action action = null;

        if (actionsToSend.Count > 0)
        {
            action = actionsToSend.Dequeue();
        }

        //if no action for this turn, send the NoAction action
        if (action == null)
        {
            action = new NoAction();
        }

        //action.NetworkAverage = Network.GetLastPing (Network.connections[0/*host player*/]);
        if (LockStepTurnID > FirstLockStepTurnID + 1)
        {
            action.NetworkAverage = confirmedActions.GetPriorTime();
        }
        else
        {
            action.NetworkAverage = initialLockStepTurnLength;
        }
        action.RuntimeAverage = Convert.ToInt32(currentGameFrameRuntime);
        //clear the current runtime average
        currentGameFrameRuntime = 0;

        //add action to our own list of actions to process
        pendingActions.AddAction(action, Convert.ToInt32(Network.player.ToString()), LockStepTurnID, LockStepTurnID);
        //start the confirmed action timer for network average
        confirmedActions.StartTimer();
        //confirm our own action
        confirmedActions.ConfirmAction(Convert.ToInt32(Network.player.ToString()), LockStepTurnID, LockStepTurnID);
        //send action to all other players
        //nv.RPC("RecieveAction", RPCMode.Others, LockStepTurnID, Network.player.ToString(), BinarySerialization.SerializeObjectToByteArray(action));

        RecieveActionMessage recieveActionMessage = new RecieveActionMessage();

        recieveActionMessage.LockStepTurnID = LockStepTurnID;
        recieveActionMessage.value          = BinarySerialization.SerializeObjectToByteArray(action);
        manager.client.Send(LockstepMsgType.RecieveAction, recieveActionMessage);

        UnityEngine.Debug.Log("Sent " + (action.GetType().Name) + " action for turn " + LockStepTurnID);
    }
コード例 #8
0
        public void AdjustRouteBySpeed()
        {
            List <TileAction> nw = new List <TileAction>();

            nw = Actions;
            for (int d = 0; d < Actions.Count - 1; d++)
            {
                if (!(Actions[d] is NoAction))
                {
                    for (int i = 0; i < this.speed; i++)
                    {
                        d++;
                        NoAction n = new NoAction();
                        Actions.Insert(d, n);
                    }
                }
            }
        }
コード例 #9
0
        public async Task Flee()
        {
            Player player;
            string log;

            if (!IsPrivate(Context.Channel, out log))
            {
                await ReplyAsync(log);

                return;
            }

            if (CheckPlayer(out player, out log) && IsInBattle(player))
            {
                Battling task   = player.task as Battling;
                Battle   battle = BattleManager.Instance.GetBattle(task.battleId);

                Random random = new Random();
                if (random.Next(0, 100) <= 50 + player.currentStats.EVA)
                {
                    await ReplyAsync("You have successfully fled!");

                    BattleManager.Instance.RemoveBattle(battle.id);
                    BattleManager.Instance.ResetPlayer(player);

                    battle = null;
                    task   = null;
                }
                else
                {
                    NoAction action = new NoAction(player);
                    battle.AddAction(action);

                    await BattleManager.Instance.PerformBattle(battle, Context.Channel);
                }
            }

            if (log != "")
            {
                await ReplyAsync(log);
            }
        }
コード例 #10
0
    private void SendPendingAction()
    {
        if (_isDedicateServer)
        {
            return;
        }
        Action action = null;

        if (_actionsToSend.Count > 0)
        {
            action = _actionsToSend.Dequeue();
        }
        //if no action for this turn, send the NoAction action
        if (action == null)
        {
            action = new NoAction();
        }
        //action.networkLagTime = Network.GetLastPing (Network.connections[0/*host player*/]);
        if (_lockStepTurnID > firstLockStepTurnID + 1)
        {
            action.networkLagTime = _confirmedActions.GetPriorTime();
        }
        else
        {
            action.networkLagTime = _initialLockStepTurnLength;
        }
        action.gameLagTime = Convert.ToInt32(_currentGameFrameRuntime);
        //clear the current runtime average
        _currentGameFrameRuntime = 0;
        //add action to our own list of actions to process
        // _pendingActions.AddAction(action, Convert.ToInt32(_localPlayerIndex), _lockStepTurnID, _lockStepTurnID);
        //start the confirmed action timer for network average
        _confirmedActions.StartTimer();
        //confirm our own action
        _confirmedActions.ConfirmAction(_localPlayerIndex, _lockStepTurnID, _lockStepTurnID);
        // _confirmedActions.AddCurrentConfirmed(Network.player);
        //send action to all other players
        _networkInterface.CallSendAction(_lockStepTurnID, _localPlayerIndex, BinarySerialization.SerializeObjectToByteArray(action));
        // Debug.Log("Sent " + (action.GetType().Name) + " action for turn " + _lockStepTurnID);
    }
コード例 #11
0
        public PanelSet(int numberOfPanels)
        {
            Panels = new List <ListView <FileSystemInfo> >();

            for (int i = 0; i < numberOfPanels; i++)
            {
                ListView <FileSystemInfo> listView = new ListView <FileSystemInfo>(10, 2, 43, i);
                Panels.Add(listView);
                listView.Current = new DirectoryInfo(
                    DriveInfo.GetDrives()
                    .Where(d => d.IsReady).ToList()
                    .First()
                    .Name);
                if (i == 0)
                {
                    Panels[i].Focused = true;
                }
                listView.Items = GetItems(Panels[i].Current);
            }

            ActionPerformer = new NoAction();
        }
コード例 #12
0
    private void SendPendingAction()
    {
        IAction action = null;

        if (actionsToSync.Count > 0)
        {
            action = actionsToSync.Dequeue();
        }
        //if no action for this turn, send the NoAction action
        if (action == null)
        {
            action = new NoAction();
        }
        //add action to our own list of actions to process
        pendingActions.AddAction(action, 1, TurnID, TurnID);
        //confirm our own action
        confirmedActions.playersConfirmedCurrentAction.Add(RoleMgr.Instance.RoleId);
        //send action to all other players
        //		nv.RPC("RecieveAction", RPCMode.Others, LockStepTurnID, Network.player.ToString(), BinarySerialization.SerializeObjectToByteArray(action));

        ActionController.Instance.SyncAction(TurnID, RoleMgr.Instance.RoleId, BinarySerialization.SerializeObjectToByteArray(action));
    }
コード例 #13
0
        public NextAction Next(Pac pac, CancellationToken cancellation)
        {
            NextAction nextAction = new NoAction(pac);

            var enemies = _gameGrid.VisibleEnemiesFrom(pac.Location).ToArray();

            if (enemies.Any())
            {
                nextAction = _enemyVisibleStrategy.Next(pac, cancellation, enemies);
                Console.Error.WriteLine($"Pac {pac.Id} has seen enemies. Next action {nextAction}");
            }

            if (!(nextAction is NoAction))
            {
                return(nextAction);
            }

            var pellets = _gameGrid.VisiblePelletsFrom(pac.Location);

            nextAction = _foodVisibleStrategy.Next(pac, cancellation, pellets.ToList());
            Console.Error.WriteLine($"Pac {pac.Id} food search. Next action {nextAction}. {(cancellation.IsCancellationRequested ? "CANCELLED" : string.Empty)}");
            return(nextAction);
        }
コード例 #14
0
    private void SendPendingAction()
    {
        IAction action = null;

        if (actionsToSend.Count > 0)
        {
            action = actionsToSend.Dequeue();
        }

        //if no action for this turn, send the NoAction action
        if (action == null)
        {
            action = new NoAction();
        }
        //add action to our own list of actions to process
        pendingActions.AddAction(action, Convert.ToInt32(Network.player.ToString()), LockStepTurnID, LockStepTurnID);
        //confirm our own action
        confirmedActions.playersConfirmedCurrentAction.Add(Network.player);
        //send action to all other players
        nv.RPC("RecieveAction", RPCMode.Others, LockStepTurnID, Network.player.ToString(), BinarySerialization.SerializeObjectToByteArray(action));

        log.Debug("Sent " + (action.GetType().Name) + " action for turn " + LockStepTurnID);
    }
コード例 #15
0
ファイル: LockStepManager.cs プロジェクト: hansmei/Iluminati
    private void SendPendingAction()
    {
        Action action = null;
        if(actionsToSend.Count > 0) {
            action = actionsToSend.Dequeue();
        }

        //if no action for this turn, send the NoAction action
        if(action == null) {
            action = new NoAction();
        }

        //action.NetworkAverage = Network.GetLastPing (Network.connections[0/*host player*/]);
        if(LockStepTurnID > FirstLockStepTurnID + 1) {
            action.NetworkAverage = confirmedActions.GetPriorTime();
        } else {
            action.NetworkAverage = initialLockStepTurnLength;
        }
        action.RuntimeAverage = Convert.ToInt32 (currentGameFrameRuntime);
        //clear the current runtime average
        currentGameFrameRuntime = 0;

        //add action to our own list of actions to process
        pendingActions.AddAction(action, Convert.ToInt32(Network.player.ToString()), LockStepTurnID, LockStepTurnID);
        //start the confirmed action timer for network average
        confirmedActions.StartTimer ();
        //confirm our own action
        confirmedActions.ConfirmAction(Convert.ToInt32(Network.player.ToString ()), LockStepTurnID, LockStepTurnID);
        //send action to all other players
        nv.RPC("RecieveAction", RPCMode.Others, LockStepTurnID, Network.player.ToString(), BinarySerialization.SerializeObjectToByteArray(action));

        log.Debug("Sent " + (action.GetType().Name) + " action for turn " + LockStepTurnID);
    }
コード例 #16
0
        public override List <Tile> Handle(List <Tile> initialTiles)
        {
            List <Tile> tiles = initialTiles;

            for (int i = 0; i < initialTiles.Count(); i++)
            {
                Tile tile = initialTiles[i];

                TileAction  action       = tile.getNextAction();
                List <Tile> updatedTiles = tiles;
                bool        canMove      = true;
                bool        lightstrue   = true;
                TileAction  nextAction   = new NoAction();

                if (tile != null && tile.Actions.Count > 0)
                {
                    nextAction = tile.Actions[0];
                }

                if (nextAction.GetType() == typeof(MoveAction))
                {
                    switch (((MoveAction)nextAction).direction)
                    {
                    case Direction.Up:
                        canMove    = checkFront(tile.Position.X, tile.Position.Y - 1, initialTiles);
                        lightstrue = !(checkTrafficLight(tile.Position.X + 1, tile.Position.Y, initialTiles) && checkRightLight(tile.Position.X + 1, tile.Position.Y - 1, initialTiles));

                        break;

                    case Direction.Down:
                        canMove    = checkFront(tile.Position.X, tile.Position.Y + 1, initialTiles);
                        lightstrue = !(checkTrafficLight(tile.Position.X - 1, tile.Position.Y, initialTiles) && checkRightLight(tile.Position.X - 1, tile.Position.Y + 1, initialTiles));
                        break;

                    case Direction.Left:
                        canMove    = checkFront(tile.Position.X - 1, tile.Position.Y, initialTiles);
                        lightstrue = !(checkTrafficLight(tile.Position.X, tile.Position.Y - 1, initialTiles) && checkRightLight(tile.Position.X - 1, tile.Position.Y - 1, initialTiles));
                        break;

                    case Direction.Right:
                        canMove    = checkFront(tile.Position.X + 1, tile.Position.Y, initialTiles);
                        lightstrue = !(checkTrafficLight(tile.Position.X, tile.Position.Y + 1, initialTiles) && checkRightLight(tile.Position.X + 1, tile.Position.Y + 1, initialTiles));
                        break;
                    }
                }
                if (nextAction.GetType() == typeof(NoAction) && tile.Type == TileType.Car)
                {
                    updatedTiles = action.Handle(tile, initialTiles);
                    return(updatedTiles);
                }

                if (!tile.Dirty && lightstrue && canMove)
                {
                    updatedTiles = action.Handle(tile, initialTiles);
                }
                else
                {
                    tile.Actions.Insert(0, action);
                }

                tiles = updatedTiles;
            }

            return(tiles);
        }