示例#1
0
        public override void Update(IGameInterface gameInterface)
        {
            if (currentActivity == null && (activityQueue == null || activityQueue.Count == 0))
            {
                this.HasFinished = true;
                return;
            }

            if (currentActivity == null || currentActivity.HasFinished)
            {
                if (currentActivity != null)
                {
                    Debug.LogFormat("SequenceActivity: Finished activity. type={0}", currentActivity.GetType());
                    currentActivity = null;

                    this.HasFinished = true;
                }

                if (activityQueue != null && activityQueue.Count > 0)
                {
                    currentActivity = activityQueue.Dequeue();
                    Debug.LogFormat("SequenceActivity: Starting activity. type={0}", currentActivity.GetType());

                    currentActivity.Start(gameInterface);
                }

                return;
            }

            currentActivity.Update(gameInterface);
        }
示例#2
0
 public override void Start(IGameInterface gameInterface)
 {
     foreach (ActivityBase activity in this.Activities)
     {
         activity.Start(gameInterface);
     }
 }
示例#3
0
        public void Initialize(IGameInterface gameInterface, FDPosition position)
        {
            this.gameInterface = gameInterface;

            this.gameObject.name = "indicator";
            this.gameObject.transform.localPosition = FieldTransform.GetObjectPixelPosition(FieldTransform.FieldObjectLayer.Ground, position.X, position.Y);
        }
示例#4
0
        public async Task OnGameOver(string why)
        {
            IGameInterface game = _GameHandler.RemoveGame(Context.ConnectionId);
            string         message;

            if (why == "forfeit")
            {
                if (game.PlayerOne.ConnectionId == Context.ConnectionId)
                {
                    UpdateRating(game.PlayerTwo, game.PlayerOne);
                }
                else
                {
                    UpdateRating(game.PlayerOne, game.PlayerTwo);
                }
                message = "A player forfeited the game, ratings have been recorded";
            }
            else
            {
                message = "A player left the game-session, ratings have been recorded";
            }
            await Clients.Groups(game.MatchId).BackToGames(message);

            await Groups.RemoveFromGroupAsync(game.PlayerOne.ConnectionId, game.MatchId);

            await Groups.RemoveFromGroupAsync(game.PlayerTwo.ConnectionId, game.MatchId);
        }
        public object UpdateBoard(int index, string connectionid)
        {
            IGameInterface game = Games.FirstOrDefault(g => g.PlayerOne.ConnectionId == connectionid || g.PlayerTwo.ConnectionId == connectionid);

            if (game != null)
            {
                if (game.PlayerOne.ConnectionId == connectionid && game.PlayerOneTurn)
                {
                    if (!game.IsPlayed(game.Board[index]))
                    {
                        game.Board[index]  = game.PlayerOneMark;
                        game.PlayerOneTurn = false;
                        return(game);
                    }
                    return("You can't place there..");
                }
                else if (game.PlayerTwo.ConnectionId == connectionid && !game.PlayerOneTurn)
                {
                    if (!game.IsPlayed(game.Board[index]))
                    {
                        game.Board[index]  = game.PlayerTwoMark;
                        game.PlayerOneTurn = true;
                        return(game);
                    }
                    return("You can't place there..");
                }
            }
            return("Wait for your turn.");
        }
示例#6
0
 public void RegisterGame(IGameInterface game_interface)
 {
     games.Add(game_interface);
     game_interface.SetServer(this);
     PlayerDropped += new EventHandler <GameConnectionEventArgs>(game_interface.OnPlayerDropped);
     NewConnection += new EventHandler <GameConnectionEventArgs>(game_interface.OnNewConnection);
 }
示例#7
0
    private void ProcessInitializeState()
    {
        this._gameInterface = this.InitializeGameMode();
        this.UiHolder.GameSettings.Initialize();
        SecurityWrapperService.Instance.ArmBox();
        switch (this.currentGameType)
        {
        case CGameManager.GAME_RULES_TYPE.Practice:
        {
            this.gameState = CGameManager.GAMESTATE.SETUP;
            break;
        }

        case CGameManager.GAME_RULES_TYPE.LongDrive:
        case CGameManager.GAME_RULES_TYPE.ClosestToPin:
        case CGameManager.GAME_RULES_TYPE.Bullseye:
        {
            this.gameState = CGameManager.GAMESTATE.OPTIONS;
            break;
        }

        case CGameManager.GAME_RULES_TYPE.SkillsAssessment:
        case CGameManager.GAME_RULES_TYPE.BagMapping:
        {
            this.gameState = CGameManager.GAMESTATE.OPTIONS;
            break;
        }
        }
    }
        public IGameInterface CreateGame(Player player1, Player player2)
        {
            IGameInterface game = _GameFactory.CreateGame(player2, player1);

            Games.Add(game);
            return(game);
        }
示例#9
0
 internal Reaction(Node node, Conversation conversation, IGameInterface gameInterface, IEnumerable<string> langs)
 {
     _node = node;
     _conversation = conversation;
     _gameInterface = gameInterface;
     _langs = langs;
 }
示例#10
0
 public EventWaitHandle Start(IGameInterface gameInterface)
 {
     WaitHandle = new AutoResetEvent(false);
     Thread     = new Thread(() => Run(gameInterface));
     Thread.Start();
     return(WaitHandle);
 }
示例#11
0
        private void Run(IGameInterface gameInterface)
        {
            Bot.SetRenderPipeline(new Rendering.RenderPipeline());

            while (!gameInterface.IsInitialized())
            {
                Thread.Sleep(100);
            }

            Console.WriteLine($"{Bot.Name} has started.");

            while (true)
            {
                var worldState = gameInterface.GetWorldState();
                if (!worldState.HasMatchEnded && worldState.IsRoundActive && worldState.Players.Count > Bot.PlayerIndex)
                {
                    var ballPrediction = gameInterface.GetBallPrediction();
                    var action         = Bot.OnTick(worldState, ballPrediction);
                    if (action != null)
                    {
                        gameInterface.PerformAction(action, Bot.PlayerIndex);
                    }
                    gameInterface.PerformRender(Bot.PlayerIndex, Bot.RenderPipeline);
                }

                WaitHandle.WaitOne();
            }
        }
        public object IsGameOver(IGameInterface game, string connectionid)
        {
            Player player;
            Player looser;

            if (game.PlayerOne.ConnectionId == connectionid)
            {
                player = game.PlayerOne;
            }
            else
            {
                player = game.PlayerTwo;
            }
            if (game.IsWon(game.Board, player))
            {
                looser = game.PlayerOne == player ? game.PlayerTwo : game.PlayerOne;
                var dict = new Dictionary <string, Player> {
                    { "Winner", player }, { "Looser", looser }
                };
                return(dict);
            }
            else if (game.GetAvailableSpots(game.Board).Count() == 0)
            {
                return("Draw");
            }
            else
            {
                return(game);
            }
        }
 public override void Start(IGameInterface gameInterface)
 {
     foreach (int creatureId in creatureIds)
     {
         UICreature creature = gameInterface.GetUICreature(creatureId);
         creature.SetAnimateState(UICreature.AnimateStates.Dying);
     }
 }
示例#14
0
        public PestisoriField()
        {
            var applicationLogic = new AppLogic.ApplicationLogic();

            _gameInterfaceAL = applicationLogic.GetGameInterfaceAL();

            InitializeComponent();
        }
示例#15
0
        public override void Start(IGameInterface gameInterface)
        {
            if (callbackAction != null && gameInterface != null)
            {
                callbackAction(gameInterface);
            }

            this.HasFinished = true;
        }
示例#16
0
 public bool TestConditions(IGameInterface gameInterface)
 {
     foreach (var condition in Conditions)
     {
         if (condition.Test(gameInterface) == false)
             return false;
     }
     return true;
 }
示例#17
0
 public UpdateInterfaceItemPacket(
     IGameInterface interf,
     IItemContainer container,
     ICollection <int> indicies)
 {
     _interf    = interf;
     _container = container;
     _indicies  = new HashSet <int>(indicies);
 }
示例#18
0
        /// <summary>
        /// Sets the Datasource to be Mock or SQL
        /// </summary>
        /// <param name="dataSourceEnum"></param>
        public static void SetDataSource(DataSourceEnum dataSourceEnum)
        {
            if (dataSourceEnum == DataSourceEnum.SQL)
            {
                // SQL not hooked up yet...
                // throw new NotImplementedException();
            }

            // Default is to use the Mock
            DataSource = GameDataSourceMock.Instance;
        }
示例#19
0
        public override void Start(IGameInterface gameInterface)
        {
            if (currentActivity == null && (activityQueue == null || activityQueue.Count == 0))
            {
                this.HasFinished = true;
                return;
            }

            currentActivity = activityQueue.Dequeue();
            currentActivity.Start(gameInterface);
        }
示例#20
0
        public void Initialize(IGameInterface gameInterface, Transform field, int chapterId, int shapeIndex, FDPosition position)
        {
            this.transform.parent = field;
            this.gameInterface    = gameInterface;
            this.fieldMapRoot     = field;

            this.chapterId  = chapterId;
            this.shapeIndex = shapeIndex;
            this.position   = position;

            this.transform.localPosition = FieldTransform.GetShapePixelPosition(position.X, position.Y);
        }
        public override void Update(IGameInterface gameInterface)
        {
            if (IsCurrentMoveDone())
            {
                // Set precise position for the UI
                if (currentVertex >= 0)
                {
                    var vertex = this.MovePath.Vertexes[currentVertex];
                    this.UICreature.SetPixelPosition(FieldTransform.GetCreaturePixelPosition(vertex));
                }

                // Pick the next vertex, or finish
                currentVertex++;
                if (currentVertex < this.MovePath.Vertexes.Count)
                {
                    var targetVertex = this.MovePath.Vertexes[currentVertex];
                    targetPosition = FieldTransform.GetCreaturePixelPosition(targetVertex);

                    FDPosition current = this.UICreature.GetCurrentPosition();
                    if (targetVertex.X > current.X)
                    {
                        this.UICreature.SetAnimateState(UICreature.AnimateStates.WalkRight);
                    }
                    else if (targetVertex.X < current.X)
                    {
                        this.UICreature.SetAnimateState(UICreature.AnimateStates.WalkLeft);
                    }
                    else if (targetVertex.Y > current.Y)
                    {
                        this.UICreature.SetAnimateState(UICreature.AnimateStates.WalkDown);
                    }
                    else if (targetVertex.Y < current.Y)
                    {
                        this.UICreature.SetAnimateState(UICreature.AnimateStates.WalkUp);
                    }
                    else
                    {
                        // Make the status to done so that next Update will pick the next vertex
                        this.UICreature.SetAnimateState(UICreature.AnimateStates.Idle);
                    }
                }
                else
                {
                    this.UICreature.SetAnimateState(UICreature.AnimateStates.Idle);
                    this.HasFinished = true;
                }

                return;
            }

            DoMoving();
        }
示例#22
0
 public Round(
     IGameInterface gameInterface, GameModes mode, int boardSize,
     int roundsToWin, int nextPlayerNumber, Player player1, Player player2
     )
 {
     this.GameInterface    = gameInterface;
     this.Mode             = mode;
     this.BoardSize        = boardSize;
     this.RoundsToWin      = roundsToWin;
     this.NextPlayerNumber = nextPlayerNumber;
     this.Player1          = player1;
     this.Player2          = player2;
 }
示例#23
0
文件: Main.cs 项目: zjljxsc/cshotfix
    private bool InitLogicPlugin()
    {
        bool hr = true;

        m_Game = new LogicMain();
        if (m_Game == null)
        {
            Debug.LogError("GameDll load fail");
            hr = false;
            Exit();
        }
        return(hr);
    }
示例#24
0
 public BulPgiaForm()
 {
     this.Text = "Bool Pgia";
     this.CenterToScreen();
     this.m_CurrGuess = new Guess(Config.k_GuessLength);
     m_MaxGuessDialog = new MaxGuessForm();
     m_MaxGuessDialog.ShowDialog();
     m_Logic = new GameEngine(m_MaxGuessDialog.StartNumOfChances);
     m_MaxGuessDialog.Close();
     m_ColorForm = new ColorForm();
     m_Logic.StartNewGame();
     m_ButtonMakeGuessList = new List <ButtonMakeGuess>();
     this.InitControls();
 }
        public IGameInterface RemoveGame(string connectionId)
        {
            IGameInterface game = Games.FirstOrDefault(p => p.PlayerOne.ConnectionId == connectionId || p.PlayerTwo.ConnectionId == connectionId);

            try
            {
                Games.Remove(game);
                return(game);
            }
            catch (Exception)
            {
                return(null);
            }
        }
示例#26
0
 public bool TryGetNode(string groupId, IGameInterface world, out Node result)
 {
     result = null;
     Group group = null;
     if (TryGetGroup(groupId, out group) == false)
         return false;
     // for each node in group call test and return the latest
     foreach (var node in group)
     {
         if (node.TestConditions(world) == true)
             result = node;
     }
     return result != null;
 }
示例#27
0
        public override void Start(IGameInterface gameInterface)
        {
            // Cursor move to the current talking creature, and show talk dialog

            if (this.ConversationId != null)
            {
                gameInterface.ShowConversationDialog(this.Creature, this.ConversationId);
            }
            else if (this.MessageId != null)
            {
                gameInterface.ShowMessageDialog(this.Creature, this.MessageId);
            }

            this.HasFinished = true;
        }
示例#28
0
        public override void Update(IGameInterface gameInterface)
        {
            bool hasFinished = true;

            foreach (ActivityBase activity in this.Activities)
            {
                if (!activity.HasFinished)
                {
                    activity.Update(gameInterface);
                    hasFinished = false;
                }
            }

            this.HasFinished = hasFinished;
        }
示例#29
0
        public void Initialize(IGameInterface gameInterface, int creatureId, int animationId)
        {
            this.gameInterface = gameInterface;
            this.CreatureId    = creatureId;

            this.AnimateState = AnimateStates.Idle;

            icon1 = AssetManager.Instance().InstantiateIconGO(this.transform, animationId, 1);
            icon2 = AssetManager.Instance().InstantiateIconGO(this.transform, animationId, 2);
            icon3 = AssetManager.Instance().InstantiateIconGO(this.transform, animationId, 3);

            var box = this.gameObject.AddComponent <BoxCollider>();

            box.size   = new Vector3(2.0f, 2.0f, 2.0f);
            box.center = new Vector3(0f, 1f, 0f);
        }
示例#30
0
        public void Initialize(IGameInterface gameInterface)
        {
            this.gameInterface = gameInterface;

            cursorDefault = AssetManager.Instance().InstantiateCursorGO(this.transform, CursorType.Default);
            //cursorRange0 = GameObjectExtension.LoadCursor(CursorType.Range0, this.transform);
            //cursorRange1 = GameObjectExtension.LoadCursor(CursorType.Range1, this.transform);
            //cursorRange2 = GameObjectExtension.LoadCursor(CursorType.Range2, this.transform);

            //cursorRange0.SetActive(false);

            var box = this.gameObject.AddComponent <BoxCollider>();

            box.size   = new Vector3(2.4f, 0.2f, 2.4f);
            box.center = new Vector3(0f, 0f, 0f);
        }
示例#31
0
        public static void ShowSidebar(
            [NotNull] this IInterfaceComponent interfaces,
            [NotNull] IGameInterface interf,
            byte sidebarIdx)
        {
            if (interfaces == null)
            {
                throw new ArgumentNullException(nameof(interfaces));
            }
            if (interf == null)
            {
                throw new ArgumentNullException(nameof(interf));
            }

            interfaces.Show(InterfaceMetadata.Sidebar(interf, sidebarIdx));
        }
        public override void Start(IGameInterface gameInterface)
        {
            this.UICreature = gameInterface.GetUICreature(this.CreatureId);
            if (this.UICreature == null)
            {
                this.HasFinished = true;
                return;
            }

            if (this.MovePath.Vertexes.Count == 0)
            {
                this.HasFinished = true;
                return;
            }

            currentVertex = -1;
        }
示例#33
0
        public void Init()
        {
            var testConsole = new FakeConsole();

            this.TestInterface = new CLI(testConsole);
            this.Mode          = GameModes.PlayerVsPlayer;

            this.Player1         = new Human();
            this.Player1.Name    = "Fry";
            this.Player1.Token   = "X";
            this.Player1.NumWins = 0;

            this.Player2         = new Human();
            this.Player2.Name    = "Leela";
            this.Player2.NumWins = 0;
            this.Player2.Token   = "O";
        }
示例#34
0
 public bool Test(IGameInterface storage)
 {
     string storageValue = storage.GetValuesAsString(Key);
     return storageValue == Value;
 }
示例#35
0
 public bool TryGetNode(Node node, IGameInterface world, out Node result)
 {
     return TryGetNode(node.TargetGroup, world, out result);
 }
示例#36
0
 public void ProcessActions(IGameInterface gameInterface)
 {
     foreach (var action in Actions)
         action.Process(gameInterface);
 }
示例#37
0
 public WebPlayer(string name, IGameInterface gameInterface)
 {
     Interface = gameInterface;
 }
示例#38
0
 public void Process(IGameInterface game)
 {
     game.SetValueAsBool(Key, true);
 }
示例#39
0
 public void Process(IGameInterface game)
 {
     double number = game.GetValueAsNumber(Key);
     number += Value;
     game.SetValueAsNumber(Key, number);
 }
示例#40
0
 public void Process(IGameInterface game)
 {
     game.SetValueAsString(Key, Value);
 }
示例#41
0
 public bool Test(IGameInterface storage)
 {
     double value = storage.GetValueAsNumber(Key);
     return Math.Abs(Value - value) < Delta;
 }
示例#42
0
 public bool Test(IGameInterface game)
 {
     return game.GetValueAsBool(Key) == true;
 }
示例#43
0
 public ConversationFactory(IGameInterface game, IEnumerable<string> langs)
 {
     _gameInterface = game;
     _langs = langs;
 }