Exemplo n.º 1
0
    public override void leaveState()
    {
        _curInputEvent = GameInputEvent.Unknow;

        if (_needDelGameObject != null)
        {
            _mainGame.GetComponent <MainGame>()._arrAllBlock.Remove(_needDelGameObject);
            _needMoveArr.Remove(_needDelGameObject);
            Destroy(_needDelGameObject);
        }

        if (_needDownGameObject != null)
        {
            _needDownGameObject.GetComponent <BlockAni>()._curState = (BlockAni.BlockState.TopDown);
        }

        for (int i = 0; i < _needMoveArr.Count; i++)
        {
            ((GameObject)_needMoveArr[i]).GetComponent <BlockAni>().setLastPosCur();
            if (_needMoveArr[i].GetComponent <BlockAni>().getPosInArry().y == GameConfig.GAMEROW - 1)
            {
                _needMoveArr[i].GetComponent <BlockAni>()._curState = (BlockAni.BlockState.TopDown);
            }
            else
            {
                _needMoveArr[i].GetComponent <BlockAni>()._curState = (BlockAni.BlockState.Stand);
            }
        }

        _needMoveArr.Clear();
    }
Exemplo n.º 2
0
        private void SendSquadQuery(GameState s, RTSSquad squad, GameInputEvent e)
        {
            squad.RecalculateGridPosition();
            Vector2 start = squad.GridPosition;
            var     swe   = e as SetWayPointEvent;
            var     ste   = e as SetTargetEvent;
            Vector2 goal  = start;

            if (swe != null)
            {
                goal = swe.Waypoint;
            }
            else if (ste != null && ste.Target != null)
            {
                goal = ste.Target.GridPosition;
            }
            float minDistSq = float.MaxValue;

            for (int u = 0; u < squad.Units.Count; u++)
            {
                RTSUnit unit   = squad.Units[u];
                float   distSq = (goal - unit.GridPosition).LengthSquared();
                if (distSq < minDistSq)
                {
                    minDistSq = distSq;
                    start     = unit.GridPosition;
                }
            }
            var query = pathfinder.ReissuePathQuery(new PathQuery(start, goal, e.Team), start, goal, e.Team);

            squadQueries.Add(new SquadQuery(squad, query));
        }
Exemplo n.º 3
0
        private void OnGameInputEvent(object sender, IGameEvent gameEvent)
        {
            GameInputEvent gameInputEvent = (GameInputEvent)gameEvent;

            switch (gameInputEvent.State)
            {
            case GameInputEvent.States.HorizontalAxisMovement:
            {
                if (_posToRot == Vector3.one)
                {
                    // start rotating camera around the ball
                    transform.RotateAround(_cueBall.position, Vector3.up, 20f * gameInputEvent.axisOffset * Time.deltaTime);
                }
                else
                {
                    // start rotating camera around _posToRot vector
                    transform.RotateAround(_posToRot, Vector3.up, 20f * gameInputEvent.axisOffset * Time.deltaTime);
                }
            }
            break;

            case GameInputEvent.States.VerticalAxisMovement:
            {
                // nothing is done here for now
            }
            break;
            }
        }
Exemplo n.º 4
0
    public override void handleInput(GameInputEvent inputevent, int configidx)
    {
        Debug.Log(inputevent);
        GameStateMove move = _mainGame.GetComponent <GameStateMove>();

        move._curInputEvent = inputevent;
        move._moveConfig    = configidx;
        _mainGame.GetComponent <MainGame>().changeStage(MainGame.GameStage.MOVE);
    }
Exemplo n.º 5
0
        private void OnGameInput(object sender, IGameEvent gameEvent)
        {
            GameInputEvent gameInputEvent = (GameInputEvent)gameEvent;

            switch (gameInputEvent.State)
            {
            case GameInputEvent.States.Paused:
                OnPause();
                break;
            }
        }
        protected IEnumerator Update()
        {
            while (true)
            {
                // Process Game Input
                GameInputEvent input = ProcessGameInput();

                if (input != GameInputEvent.Null)
                {
                    gameInputSignal.Dispatch(input);
                }

                yield return(null);
            }
        }
Exemplo n.º 7
0
 // Adds Event To Concurrent Queue
 public void AddEvent(GameInputEvent e)
 {
     eventQueue.Enqueue(e);
 }
Exemplo n.º 8
0
 public abstract void handleInput(GameInputEvent inputevent, int configidx);
Exemplo n.º 9
0
 public override void handleInput(GameInputEvent inputevent, int configidx)
 {
 }
Exemplo n.º 10
0
        private void OnGameInputEvent(object sender, IGameEvent gameEvent)
        {
            GameInputEvent gameInputEvent = (GameInputEvent)gameEvent;

            // start moving the cue stick towards the ball
            switch (gameInputEvent.State)
            {
            case GameInputEvent.States.HorizontalAxisMovement:
            {
                if (_posToRot == Vector3.one)
                {
                    transform.RotateAround(_cueBall.position, Vector3.up, 20f * gameInputEvent.axisOffset * Time.deltaTime);
                }
                else
                {
                    transform.RotateAround(_posToRot, Vector3.up, 20f * gameInputEvent.axisOffset * Time.deltaTime);
                }
            }
            break;

            case GameInputEvent.States.VerticalAxisMovement:
            {
                // this means that the ball is moving
                if (_posToRot != Vector3.one)
                {
                    return;
                }

                // clamp the cue movement, else it will be frustrating for the player
                var newPosition = transform.position + transform.forward * gameInputEvent.axisOffset;

                _forceGathered = Vector3.Distance(_cueBall.position, newPosition);
                if ((_forceGathered < _defaultDistFromCueBall + _maxClampDist) &&
                    _forceGathered > _defaultDistFromCueBall)
                {
                    transform.position = newPosition;
                    EventManager.Notify(typeof(CueActionEvent).ToString(), this, new CueActionEvent()
                        {
                            ForceGathered = _forceGathered
                        });
                }
                else
                {
                }
            }
            break;

            case GameInputEvent.States.Release:
            {
                // the cue ball is not stationary as of now
                if (_posToRot != Vector3.one)
                {
                    return;
                }

                if (_forceGathered > _defaultDistFromCueBall + _forceThreshold)
                {
                    _cueReleasedToStrike = true;
                }
            }
            break;
            }
        }