コード例 #1
0
ファイル: Hero.cs プロジェクト: SayanSuresh/gamesayan
        private void move(Vector2 _direction)
        {
            if (_direction.X == -1)
            {
                currentAnimation = walkLeft;
            }
            else if (_direction.X == 1)
            {
                currentAnimation = walkRight;
            }
            else if (_direction.Y == -1)
            {
                currentAnimation = walkUp;
            }
            if (_direction.X == 0 && _direction.Y == 0)
            {
                currentAnimation = walkDown;
            }

            //jumping movement
            if (_direction.Y == -1 && HasJumped == false)
            {
                Velocity  = new Vector2(Velocity.X, -10f);
                HasJumped = true;
            }

            Position += Velocity;
            if (Velocity.Y < 20)
            {
                Velocity += new Vector2(Velocity.X, 0.9f);
            }

            moveCommand.Execute(this, _direction);
        }
コード例 #2
0
ファイル: Hero.cs プロジェクト: SayanSuresh/testCode
        private void move(Vector2 _direction)
        {
            if (_direction.X == -1)
            {
                currentAnimation = walkLeft;
            }
            else if (_direction.X == 1)
            {
                currentAnimation = walkRight;
            }
            else if (_direction.Y == -1)
            {
                currentAnimation = walkUp;
            }
            if (_direction.X == 0 && _direction.Y == 0)
            {
                currentAnimation = walkDown;
            }

            //jumping movement
            if (_direction.Y == -1 && hasJumped == false)
            {
                velocity.Y = -9f;
                hasJumped  = true;
            }


            Position += velocity;
            if (velocity.Y < 20)
            {
                velocity.Y += 0.9f;
            }

            moveCommand.Execute(this, _direction);
        }
コード例 #3
0
        /// <summary>
        /// Entry point for all commands execution.
        /// </summary>
        /// <param name="current"> Current session.</param>
        /// <param name="sessions">Collection of all sessions.</param>
        /// <param name="message">Message sent by chat cient.</param>
        internal static void HandleGameMessage(JigsawGameService current, GameSessions sessions, string message)
        {
            string command     = string.Empty;
            string commandArgs = string.Empty;

            var index = message.IndexOf(":", StringComparison.OrdinalIgnoreCase);

            if (index > 0)
            {
                command     = message.Substring(0, index);
                commandArgs = message.Substring(index + 1, message.Length - index - 1);
            }
            else
            {
                command = message;
            }

            Logger.LogMessage(command);
            Logger.LogMessage(commandArgs);

            IGameCommand handler = null;

            if (commands.TryGetValue(command, out handler))
            {
                handler.Execute(current, sessions, commandArgs);
            }
        }
 public void Execute()
 {
     if (inputReader.ReadMoveInput())
     {
         if (inputReader.ReadMoveLeftInput() && inputReader.ReadMoveRightInput() == false)
         {
             Orientation.X = -1;
         }
         if (inputReader.ReadMoveRightInput() && inputReader.ReadMoveLeftInput() == false)
         {
             Orientation.X = 1;
         }
         moveCommand.Execute();
         SetState(EntityState.Run);
     }
     if (inputReader.ReadJumpInput() && HasJumped == false)
     {
         jumpCommand.Execute();
         SetState(EntityState.Jump);
     }
     if (inputReader.ReadMoveInput() == false && inputReader.ReadJumpInput() == false)
     {
         SetState(EntityState.Idle);
         Velocity.X = 0;
     }
 }
コード例 #5
0
 public void Handle()
 {
     if (currentCommand != null)
     {
         currentCommand.Execute();
     }
 }
コード例 #6
0
 protected override void OnUpdate()
 {
     base.OnUpdate();
     if (DouDiZhuGameCtrl.Instance.CommandQueue.Count > 0)
     {
         IGameCommand command = DouDiZhuGameCtrl.Instance.CommandQueue.Dequeue();
         command.Execute();
     }
 }
コード例 #7
0
        /// <summary>
        /// Executes Command on local copy of GameState. Use it from DataHandler when JSON command arrives from server.
        /// </summary>
        /// <param name="cmd">Command to be executed</param>
        public void UpdateState(IGameCommand cmd)
        {
            if (cmd == null)
            {
                return;
            }

            cmd.Execute(gameState);
            stateUpdated?.Invoke(gameState);
        }
        /// <summary>
        /// Executes a Command and broadcasts it to all clients.
        /// </summary>
        /// <param name="cmd">Command to be executed and broadcasted</param>
        public void Execute(IGameCommand cmd)
        {
            if (cmd == null)
            {
                return;
            }

            cmd.Execute(gameState);
            this.server.SendToAll(cmd);

            stateUpdated?.Invoke(gameState);
        }
コード例 #9
0
        public void ExecuteCommand(IGameCommand cmd)
        {
            cmd.Execute();

            _undoStack.Push(cmd);
            OnPropertyChanged("UndoStackCount");

            if (_redoStack.Count > 0)
            {
                _redoStack.Clear();
                OnPropertyChanged("RedoStackCount");
            }
        }
コード例 #10
0
ファイル: Hero.cs プロジェクト: tomptrs/GameDev-Animations
        private void MoveHorizontal(Vector2 _direction)
        {
            if (_direction.X == -1)
            {
                currentAnimation = walkLeft;
            }
            else if (_direction.X == 1)
            {
                currentAnimation = walkRight;
            }

            moveCommand.Execute(this, _direction);
        }
コード例 #11
0
        protected override void OnUpdate()
        {
            base.OnUpdate();
            if (ShiSanZhangGameCtrl.Instance.CommandQueue.Count > 0)
            {
                IGameCommand command = ShiSanZhangGameCtrl.Instance.CommandQueue.Dequeue();
                command.Execute();
            }

            if (!m_IsSelectedPoker && Input.GetMouseButtonDown(0))
            {
                if (RoomShiSanZhangProxy.Instance.CurrentRoom.SszRoomStatus != ROOM_STATUS.ROOM_STATUS_MATEPOKER)
                {
                    return;
                }

                Ray ray = m_UISceneShiSanZhangView.CurrentCamare.ScreenPointToRay(Input.mousePosition);

                RaycastHit hit;
                if (Physics.Raycast(ray, out hit, Mathf.Infinity))
                {
                    Debug.Log("-------------Ray ray -----------------");
                    if (hit.transform.gameObject.layer != 1 << LayerMask.NameToLayer("PlayerHand"))
                    {
                        return;
                    }
                }
                UIItemPoker_ShiSanZhang ctrl = GetRayHitPoker();
                if (ctrl != null)
                {
                    m_EndSelectedPoker = null;   //结束选中的牌
                    m_CurrSelectedPoker.Clear(); //当前拖拽选中的牌
                    //获得第一张牌
                    m_StartSelectedPoker = ctrl;
                    m_CurrSelectedPoker.Add(ctrl);
                    m_IsSelectedPoker = true;
                    ctrl.SetSelected(true);
                }
            }
            if (m_IsSelectedPoker && Input.GetMouseButtonUp(0))
            {
                for (int i = 0; i < m_CurrSelectedPoker.Count; ++i)
                {
                    m_CurrSelectedPoker[i].SetSelected(false);
                    m_CurrSelectedPoker[i].isSelect = !m_CurrSelectedPoker[i].isSelect;
                }
                ResetDragPoker();
                UITipPokerShiSanZhangView.Instance.TipKuang();
            }
        }
コード例 #12
0
        public void Update()
        {
            // jumping movement
            if (reader.ReadInput().Y == -1 && HasJumed == false)
            {
                velocity.Y = -9f;
                HasJumed   = true;
            }

            Position += velocity;
            if (velocity.Y < 20)
            {
                velocity.Y += 0.9f;
            }

            moveCommand.Execute(this, reader.ReadInput());
        }
コード例 #13
0
        /// <summary>
        /// Executes and parses a command.
        /// </summary>
        /// <param name="cmdRaw">The command to execute / parse</param>
        private void ExecParseCmd(string cmdRaw)
        {
            if (string.IsNullOrEmpty(cmdRaw))
            {
                return;
            }
            // Match the input and split the command into arguments (space, excluding when in quotes)
            Regex         cmdRegex = new Regex(@"\w+|""[\w\s]*""");
            List <Match>  matches  = cmdRegex.Matches(cmdRaw).Cast <Match>().ToList();
            List <string> argsRaw  = new List <string>();

            foreach (Match m in matches)
            {
                string matchVal = m.Value;
                if (matchVal.StartsWith("\""))
                {
                    matchVal = matchVal.Substring(1);
                }
                if (matchVal.EndsWith("\""))
                {
                    matchVal = matchVal.Substring(0, matchVal.Length - 1);
                }
                argsRaw.Add(matchVal);
            }
            if (argsRaw.Count < 1)
            {
                return;
            }
            string parsedCmd = argsRaw[0];
            // Search for the command
            List <IGameCommand> matchingCommands = CommandRegistry.Keys.Select(k => CommandRegistry[k]).Where(v => v.Command == parsedCmd).ToList();

            if (matchingCommands.Count < 1)
            {
                // Invalid command
                Log(CStr("Command '" + parsedCmd + "' not found.", Color.red));
                return;
            }
            IGameCommand  command     = matchingCommands.First();
            List <string> commandArgs = argsRaw.Skip(1).ToList();

            Debug.Log("[CommandEnvironment] Executing command '" + command.UIDString + "'.");
            Log(CStr("Execute <" + command.Command + ">:", Color.yellow));
            command.Execute(commandArgs);
        }
コード例 #14
0
        protected override void OnUpdate()
        {
            base.OnUpdate();

            if (PaoDeKuaiGameCtrl.Instance.CommandQueue.Count > 0)
            {
                IGameCommand command = PaoDeKuaiGameCtrl.Instance.CommandQueue.Dequeue();
                command.Execute();
            }
            if (!m_IsSelectedPoker && Input.GetMouseButtonDown(0))
            {
                StartSelectedPoker();
            }
            if (m_IsSelectedPoker && Input.GetMouseButtonUp(0))
            {
                EndSelectedPoker();
            }
        }
コード例 #15
0
        public void Update(GameTime gameTime, SoundEffect spring)
        {
            walk.Update(gameTime);

            Movecommand.Execute(gameTime, this, inputReader.LeesInput(), spring);

            _collisionRectangle.X = (int)positie.X;
            _collisionRectangle.Y = (int)positie.Y;
            CollisionRectangle    = _collisionRectangle;

            colli.Update(gameTime, CollisionRectangle, backgroundsize, Movecommand);

            foreach (var sprite in kogels.ToArray())
            {
                sprite.Update(gameTime, kogels, walk.sprite, this);
            }

            DeleteBullet();
        }
コード例 #16
0
 public GameStatus ExecuteCommand(IGameCommand command)
 {
     command.Execute(State);
     if (State.Any(spaceState => spaceState == GameSpaceState.Mine))
     {
         return(GameStatus.Loss);
     }
     else if (State.Count(spaceState =>
                          spaceState == GameSpaceState.Blank ||
                          spaceState == GameSpaceState.Flag)
              == State.MineCount)
     {
         return(GameStatus.Win);
     }
     else
     {
         return(GameStatus.Ongoing);
     }
 }
        private void Move(Vector2 _direction)
        {
            //jumping movement
            if (_direction.Y == -1 && HasJumped == false)
            {
                Velocity  = new Vector2(Velocity.X, -7f);
                HasJumped = true;
                hasJumped = !hasJumped;
            }


            Position += Velocity;

            if (!OnGround && Velocity.Y < 10)
            {
                Velocity += new Vector2(Velocity.X, 0.6f);
            }


            moveCommand.Execute(this, _direction);
        }
コード例 #18
0
 private void MoveHorizontal(Vector2 _direction)
 {
     movecommand.Execute(this, _direction);
     effect = movecommand.Direction(_direction);
 }
コード例 #19
0
 private void Move(Vector2 mouse)
 {
     moveToCommand.Execute(this, mouse);
 }
コード例 #20
0
 private void MoveHorizontal(Vector2 _direction)
 {
     moveCommand.Execute(this, _direction);
 }
コード例 #21
0
 private void Move(Vector2 direction)
 {
     moveCommand.Execute(this, direction, this);
 }
コード例 #22
0
        public void ExecuteCommand(IGameCommand cmd)
        {
            cmd.Execute();

            _undoStack.Push(cmd);
            OnPropertyChanged("UndoStackCount");

            if (_redoStack.Count > 0)
            {
                _redoStack.Clear();
                OnPropertyChanged("RedoStackCount");
            }
        }