Ejemplo n.º 1
0
 public EnemyAttack(EDirection _direction)
 {
     direction = _direction;
     animState = EAnimState.Attacking;
     timer = 0;
     hitTime = 500;
 }
Ejemplo n.º 2
0
 public void ChangeGhostDirection(int?id, EDirection direction)
 {
     this.SendCommand(new ChangeGhostDirection()
     {
         Id = id, Direction = (ECommandDirection?)direction
     });
 }
Ejemplo n.º 3
0
        public void Add(Trade trade, Quote quote)
        {
            double midpoint = (quote.Bid + quote.Ask) / 2;

            if (trade.Price == midpoint)
            {
                switch (direction)
                {
                case EDirection.accumulate:
                    accum += trade.Size;
                    break;

                case EDirection.distribute:
                    accum -= trade.Size;
                    break;
                }
            }
            else
            {
                if (trade.Price > midpoint)
                {
                    accum    += trade.Size;
                    direction = EDirection.accumulate;
                }
                if (trade.Price < midpoint)
                {
                    accum    -= trade.Size;
                    direction = EDirection.distribute;
                }
            }
            base.Add(trade.DateTime, accum);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Find a Platform from a given position and direction
 /// used for the ball to know if its running into a platform, or if
 /// rolling off an edge
 /// </summary>
 /// <param name="pos"></param>
 /// <param name="dir"></param>
 /// <returns></returns>
 Platform RaycastForPlatform(Vector3 pos, EDirection dir)
 {
     return(Physics.RaycastAll(pos, dir.ToVec(), 1.0f)
            .Select(o => o.collider.GetComponent <Platform>())
            .Where(o => o != null)
            .FirstOrDefault());
 }
Ejemplo n.º 5
0
 public Climby(CoordHelper.EProfile pt)
     : base(App.Game)
 {
     playerType = pt;
     if (playerType == CoordHelper.EProfile.ONEPLAYER)
         skin = SpriteManager.ESprite.CLIMBYBLUE;
     else
         skin = SpriteManager.ESprite.CLIMBYRED;
     pos = new Vector2(CoordHelper.Instance.getLeftMargin(playerType) + Constants.Measures.boardWidth / 2,
                           Constants.Measures.upBoardMargin + Constants.Measures.boardHeight - Constants.Measures.blockSize);
     actualPosition = new Rectangle((int)pos.X, (int)pos.Y, (int)Constants.Measures.blockSize, (int)Constants.Measures.blockSize);
     deadZone = new Rectangle((int)pos.X + (int)(Constants.Measures.blockSize / 3),
                              (int)pos.Y + (int)(Constants.Measures.blockSize / 3), (int)(Constants.Measures.blockSize / 3), (int)(Constants.Measures.blockSize / 3));
     actions = new Dictionary<EState, Action<GameTime>>();
     #region Actions
     actions.Add(EState.CLIMB, climb);
     actions.Add(EState.END_CLIMB, move);
     actions.Add(EState.FALL, move);
     actions.Add(EState.FREE_FALL, fall);
     actions.Add(EState.MOVE, move);
     actions.Add(EState.STOP, stop);
     #endregion
     state = EState.MOVE;
     direction = EDirection.RIGHT;
     rotation = 0f;
     setSpeedFromLevel(0);
     influence = 1f;
     minHeight = (int)((pos.Y - Constants.Measures.upBoardMargin) / Constants.Measures.blockSize);
     oldMinHeight = minHeight;
 }
Ejemplo n.º 6
0
    private void GetPivotOffsetAndAxis(EDirection dir, out Vector3 pivot, out Vector3 axis)
    {
        pivot = Vector3.zero;
        axis  = Vector3.zero;
        Vector3 dirVec = dir.ToVec();

        switch (dir)
        {
        case EDirection.FORWARD:
            pivot = new Vector3(0, -0.5f, 0.5f);
            break;

        case EDirection.BACKWARD:
            pivot = new Vector3(0, -0.5f, -0.5f);
            break;

        case EDirection.LEFT:
            pivot = new Vector3(-0.5f, -0.5f, 0);
            break;

        case EDirection.RIGHT:
            pivot = new Vector3(0.5f, -0.5f, 0);
            break;
        }


        axis = Vector3.Cross(Vector3.up, dirVec);


        Vector3 scale = GetRotatedScale(target.transform.rotation);

        pivot.x *= scale.x;
        pivot.y *= scale.y;
        pivot.z *= scale.z;
    }
Ejemplo n.º 7
0
    private static Tile TryGetCoordinates(Vector2Int origin, EDirection direction)
    {
        var directionalVector = new Vector2Int();

        switch (direction)
        {
        case EDirection.Up:
            directionalVector = new Vector2Int(-1, 0);
            break;

        case EDirection.Right:
            directionalVector = new Vector2Int(0, 1);
            break;

        case EDirection.Down:
            directionalVector = new Vector2Int(1, 0);
            break;

        case EDirection.Left:
            directionalVector = new Vector2Int(0, -1);
            break;;
        }

        if (TILES_DICTIONARY.ContainsKey(origin + directionalVector))
        {
            return(TILES_DICTIONARY[origin + directionalVector]);
        }
        Debug.LogError("A tile has coordinates pointing outside of the map!");
        return(null);
    }
Ejemplo n.º 8
0
 void Start()
 {
     tPosWater = this.transform.position;
     m_Direction = EDirection.E_Tide_Low;
     mRender = this.GetComponent<Renderer>();
     tOffSet = mRender.material.GetTextureOffset("_MainTex");
 }
Ejemplo n.º 9
0
        protected override Object SpecialInputs(ConsoleKey cki, EDirection currentDirection, EGameState gameState) {
            switch (cki) {
                case ConsoleKey.Escape:
                    if (gameState == EGameState.Running)
                        return gameState == EGameState.Running ? EGameState.Over : EGameState.Running;
                    if (gameState == EGameState.Over || gameState == EGameState.Init)
                        Environment.Exit(0);
                    break;
                case ConsoleKey.Spacebar:
                    return gameState == EGameState.Running ? EGameState.Paused : EGameState.Running;
                case ConsoleKey.Q:
                    if (gameState == EGameState.Init)
                        Environment.Exit(0);
                    if (gameState == EGameState.Over)
                        StartupManager.Reset();
                    break;
                case ConsoleKey.P:
                    if (gameState == EGameState.Init)
                        return EGameState.Running;
                    break;
            }

            if (cki == ConsoleKey.UpArrow && currentDirection != EDirection.South)
                return EDirection.North;
            if (cki == ConsoleKey.RightArrow && currentDirection != EDirection.West)
                return EDirection.East;
            if (cki == ConsoleKey.DownArrow && currentDirection != EDirection.North)
                return EDirection.South;
            if (cki == ConsoleKey.LeftArrow && currentDirection != EDirection.East)
                return EDirection.West;
            return cki;
        }
Ejemplo n.º 10
0
    private void _NowKick()
    {
        EDirection      curDirection = MHeroController.CurDirection();
        SGridCoordinate forwardCoor  = Definition.GetNextCoorinate(MHeroController.MCurCoordinate, curDirection);

        MissionManager.I.KickBackBall(MHeroController.MCurCoordinate, forwardCoor);
    }
Ejemplo n.º 11
0
        private static void loadFan(String s)
        {
            string[] data   = s.Split(':');
            float    width  = float.Parse(data[2]) * MULTI;
            float    height = float.Parse(data[3]) * MULTI;
            float    x      = float.Parse(data[0]) * MULTI;
            float    y      = (float.Parse(data[1]) * MULTI * -1) - height;

            int        power     = int.Parse(data[4]);
            EDirection direction = EDirection.UP;

            switch (data[5])
            {
            case "UP": direction = EDirection.UP; break;

            case "DOWN": direction = EDirection.DOWN; break;

            case "LEFT": direction = EDirection.LEFT; break;

            case "RIGHT": direction = EDirection.RIGHT; break;
            }

            FanTile tile = new FanTile(new Vector2(x, y));

            tile.setRectangle((int)x, (int)y, (int)width, (int)height);
            tile.setPower(power);
            tile.setDirection(direction);
            if (data.Length == 7)
            {
                int time = int.Parse(data[6]);
                tile.setTime(time);
            }

            Game1.middle.Add(tile);
        }
Ejemplo n.º 12
0
    //Get the current hand direction
    EDirection GetClosestDirection(ref bool a_bDetected)
    {
        DetectionManager.DetectionHand detectionHand = DetectionManager.Get().GetHand(m_Hand);

        if (!detectionHand.IsSet())
        {
            a_bDetected = false;
            return(EDirection.eDownwards);
        }

        Vector3 handDirection = detectionHand.GetHandAxis(m_HandAxis);

        float      currentDistance = float.MaxValue;
        EDirection currentDir      = EDirection.eUpwards;

        foreach (EDirection dir in m_DirectionMap.Keys)
        {
            float newDistance = Vector3.Distance(handDirection, m_DirectionMap[dir]);

            if (newDistance < currentDistance)
            {
                currentDistance = newDistance;
                currentDir      = dir;
                a_bDetected     = true;
            }
        }

        return(currentDir);
    }
Ejemplo n.º 13
0
        private void GetMeleePosition(Grid p_grid, Party p_party, List <GridSlot> p_slots)
        {
            EDirection oppositeDir = EDirectionFunctions.GetOppositeDir(p_party.Direction);
            EDirection p_dir       = EDirectionFunctions.Add(p_party.Direction, 3);
            EDirection p_dir2      = EDirectionFunctions.Add(p_party.Direction, 1);
            EDirection direction   = p_party.Direction;
            Int32      num         = Random.Range(0, 13);
            GridSlot   neighborSlot;

            if (num >= 5)
            {
                neighborSlot = p_grid.GetSlot(p_party.Position).GetNeighborSlot(p_grid, oppositeDir);
            }
            else if (num >= 3)
            {
                neighborSlot = p_grid.GetSlot(p_party.Position).GetNeighborSlot(p_grid, p_dir);
            }
            else if (num >= 1)
            {
                neighborSlot = p_grid.GetSlot(p_party.Position).GetNeighborSlot(p_grid, p_dir2);
            }
            else
            {
                neighborSlot = p_grid.GetSlot(p_party.Position).GetNeighborSlot(p_grid, direction);
            }
            if (neighborSlot.IsPassable(m_owner, false))
            {
                m_targetSlot = neighborSlot;
            }
            else
            {
                m_targetSlot = p_slots[Random.Range(0, p_slots.Count)];
            }
        }
        public override Int32 GetTargets(List <Object> buffer)
        {
            Grid       grid              = LegacyLogic.Instance.MapLoader.Grid;
            Party      party             = LegacyLogic.Instance.WorldManager.Party;
            Position   position          = party.Position;
            EDirection direction         = party.Direction;
            Int32      rangedAttackRange = party.SelectedCharacter.FightValues.RangedAttackRange;
            Monster    monster           = party.SelectedMonster;

            if (monster == null || !grid.LineOfSight(party.Position, monster.Position, true))
            {
                monster = grid.GetRandomMonsterInDirection(position, direction, rangedAttackRange);
            }
            if (monster != null && !monster.IsAttackable)
            {
                GridSlot slot = grid.GetSlot(monster.Position);
                foreach (MovingEntity movingEntity in slot.Entities)
                {
                    Monster monster2 = movingEntity as Monster;
                    if (monster2 != null && monster2.IsAttackable)
                    {
                        monster = monster2;
                        break;
                    }
                }
            }
            if (monster != null)
            {
                buffer.Add(monster);
                return(1);
            }
            return(0);
        }
Ejemplo n.º 15
0
    void Move()
    {
        int iCheckCol = m_Char.m_iCol;
        int iCheckRow = m_Char.m_iRow;

        switch (m_Direction) {
        case EDirection.left:
            iCheckCol -= 1;
            break;
        case EDirection.right:
            iCheckCol += 1;
            break;
        case EDirection.up:
            iCheckRow += 1;
            break;
        case EDirection.down:
            iCheckRow -= 1;
            break;
        }

        square checkSquare = m_Char.m_Board.GetSquare(iCheckCol, iCheckRow);

        // walkable
        if (checkSquare != null && checkSquare.GetAlive() == false)
        m_Char.Move(m_Direction);
        // not walkable
        else
        m_Direction = Foo.GetLeft(m_Direction);
    }
Ejemplo n.º 16
0
    private void MoveToSignDirection()
    {
        Vector3[] path = new Vector3[0];

        Direction = AgentSettings.Instance.GetSignDirection();

        StartCoroutine(_ShowExclamation());

        switch (Direction)
        {
        case EDirection.LEFT:
            path = AgentSettings.Instance.PathToLeft;
            break;

        case EDirection.MIDDLE:
            path = AgentSettings.Instance.PathToMiddle;
            break;

        case EDirection.RIGHT:
            path = AgentSettings.Instance.PathToRight;
            break;
        }

        m_currentMovement = transform.DOPath(path,
                                             AgentSettings.Instance.TimeToMoveFromCenterToCreature,
                                             PathType.Linear)
                            .OnComplete(PathEnd)
                            .SetEase(Ease.Linear);
        StartCoroutine(_ScaleAlongJourney(m_currentMovement));
    }
Ejemplo n.º 17
0
    public override bool Detected()
    {
        if (DetectionManager.Get().IsHandSet(m_Hand) && m_CoolDownLeft <= 0.0f)
        {
            EDirection swipeDir = EDirection.eRight;

            if (IsSwiping(ref swipeDir))
            {
                if (swipeDir == EDirection.eLeft)
                {
                    swipeLeft = true;

                    if (gapLeft == false)
                    {
                        timeLeft = timeGap;
                        gapLeft  = true;
                    }
                }
                if (swipeLeft && timeLeft > 0.1f && timeLeft < 0.5f)
                {
                    gapLeft = false;

                    if (swipeDir == EDirection.eRight)
                    {
                        swipeLeft      = false;
                        m_CoolDownLeft = m_CooldownTime;
                        return(true);
                    }
                }
            }
        }
        return(false);
    }
Ejemplo n.º 18
0
        public static void Go(ECommand command, Position position, EDirection direction)
        {
            switch (command)
            {
            case ECommand.PLACE:
                table.Place(turtle, position, direction);
                break;

            case ECommand.MOVE:
                table.Move(turtle);
                break;

            case ECommand.LEFT:
                turtle.Left();
                break;

            case ECommand.RIGHT:
                turtle.Right();
                break;

            case ECommand.REPORT:
                var output = turtle.Report();

                if (!string.IsNullOrEmpty(output))
                {
                    Console.WriteLine($"\n-- OUTPUT --\n {output} \n \n -- INPUT --");
                }

                break;

            default:
                Console.WriteLine($"{command} is not a valid Command.");
                break;
            }
        }
Ejemplo n.º 19
0
 void AIDead()
 {
     // When aligned with the entrance, go down. When the ghost has fully entered the house,
     // stateEval will change state to Home.
     if (position_.Tile.Y == 11 && position_.Tile.X == 13 && position_.DeltaPixel.X == 8)
     {
         direction_ = EDirection.Down;
     }
     // Otherwise, only change direction if the ghost is exactly on a tile
     else if (position_.DeltaPixel == Point.Zero)
     {
         // We direct the ghost towards one of the two squares above the home. When he reaches one,
         // he still has to move slightly right or left in order to align with the entrance.
         if (position_.Tile.X == 13 && position_.Tile.Y == 11)
         {
             direction_ = EDirection.Right;
         }
         else if (position_.Tile.X == 14 && position_.Tile.Y == 11)
         {
             direction_ = EDirection.Left;
         }
         // Otherwise, when at a junction, head for the square above home closest to us.
         else if (IsAJunction(position_.Tile))
         {
             if (position_.Tile.X > 13)
             {
                 direction_ = FindDirection(new Point(14, 11));
             }
             else
             {
                 direction_ = FindDirection(new Point(13, 11));
             }
         }
     }
 }
Ejemplo n.º 20
0
    void startMovement()
    {
        _nextDirection            = _currentlyQueuedDirection;
        _currentlyQueuedDirection = EDirection.NONE;
        changeDirection(_nextDirection);
        Vector2Int nextTilePos = _position + _inputManager.GetVector(_nextDirection);
        Vector3Int nextPos     = _grid.LocalToCell(new Vector3(nextTilePos.x, nextTilePos.y));
        TileBase   tile        = _collisionMap.GetTile(nextPos);

        if (tile != null)
        {
            Debug.Log("Tile should be blocked: " + tile.ToString());
            _targetBlocked = true;
        }
        else
        {
            _position = nextTilePos;
            _currentTrapTileList.Clear();
            if (_trapMap.TileHasTrap(nextPos))
            {
                GameObject trapTile = _trapMap.GetTrapTileList(nextPos)[0];
                Debug.Log("trapTile: " + (trapTile != null));

                if (trapTile != null)
                {
                    _currentTrapTileList = _trapMap.GetTrapTileList(nextPos);
                }
            }
        }
    }
Ejemplo n.º 21
0
    private void Update()
    {
        // @request 위치 전달/수신
        Vector3       player1_pos = player1.transform.position;
        StructRequest request     = new StructRequest();

        request.uid                      = Const.UserData.uid;
        request.request_url              = URL.SyncMovement.ToString();
        request.parameter                = new Dictionary <string, string>();
        request.parameter["posX"]        = player1.gameObject.transform.position.x.ToString();
        request.parameter["posY"]        = player1.gameObject.transform.position.y.ToString();
        request.parameter["opponentUid"] = Const.UserData.opponentUid;

        void CallBack(StructRequest response)
        {
            if (!response.parameter.ContainsKey("opponentPosX"))
            {
                return;
            }

            // 받은 player2 위치 적용
            float      x        = float.Parse(response.parameter["opponentPosX"]);
            float      y        = float.Parse(response.parameter["opponentPosY"]);
            Vector3    next_pos = new Vector3(x, y, player2.transform.position.z);
            EDirection dir      = JUtils.GetDir(next_pos, player2.transform.position);

            player2.Move(dir);
            player2.transform.position = next_pos;
        }

        mNEt.SetCallBack(CallBack);
        mNEt.RequestMsg(request);
    }
Ejemplo n.º 22
0
    protected override void SetPressedGraphics(EDirection dir, bool pressed)
    {
        // only change pressed state if we're in joystick mode (and thus collision detection is off).
        // otherwise, the buttons handle the pressed graphics state themselves (during their collision detection).
        if (!JoystickMode)
        {
            return;
        }

        if (dir == EDirection.Left && LeftButton != null)
        {
            LeftButton.ForcePressed = pressed;
        }

        if (dir == EDirection.Right && RightButton != null)
        {
            RightButton.ForcePressed = pressed;
        }

        if (dir == EDirection.Up && UpButton != null)
        {
            UpButton.ForcePressed = pressed;
        }

        if (dir == EDirection.Down && DownButton != null)
        {
            DownButton.ForcePressed = pressed;
        }
    }
Ejemplo n.º 23
0
    public void GiveInfluence()
    {
        EDirection       direction = m_movement.Direction;
        InfluenceToValue infToVal  = SatisfactionGaugeSettings.Instance.InfluenceToValues.Find(e => e.Influence == Influence);

        OnBeingEaten?.Invoke(this, direction, infToVal.Value);
    }
Ejemplo n.º 24
0
        private void RotateCopies(EDirection direction)
        {
            SpriteRenderer extendedSprite = null;

            if (direction == EDirection.Right)
            {
                extendedSprite = _copies[(int)Position.Left];
                extendedSprite.transform.localPosition = new Vector3(
                    _copies[(int)Position.Right].transform.localPosition.x + _boundsSizeX,
                    extendedSprite.transform.localPosition.y,
                    extendedSprite.transform.localPosition.z
                    );

                _copies[(int)Position.Left]    = _copies[(int)Position.Central];
                _copies[(int)Position.Central] = _copies[(int)Position.Right];
                _copies[(int)Position.Right]   = extendedSprite;
            }
            else if (direction == EDirection.Left)
            {
                extendedSprite = _copies[(int)Position.Right];
                extendedSprite.transform.localPosition = new Vector3(
                    _copies[(int)Position.Left].transform.localPosition.x - _boundsSizeX,
                    extendedSprite.transform.localPosition.y,
                    extendedSprite.transform.localPosition.z
                    );

                _copies[(int)Position.Right]   = _copies[(int)Position.Central];
                _copies[(int)Position.Central] = _copies[(int)Position.Left];
                _copies[(int)Position.Left]    = extendedSprite;
            }
        }
Ejemplo n.º 25
0
        public void SetDirection(EDirection direction)
        {
            if (ComPort == null)
            {
                Trace.WriteLineIf(IsDebug, "No associated com port", Severity.Error);
                return;
            }
            if (!ComPort.IsOpen)
            {
                Trace.WriteLineIf(IsDebug, "Com port is not opened", Severity.Error);
                return;
            }

            try {
                Trace.WriteLineIf(IsDebug, $"Set direction to {direction.ToString()}");
                if (direction == EDirection.Clockwise)
                {
                    ComPort.Write("D");
                }
                else
                {
                    ComPort.Write("d");
                }
            } catch (Exception ex) {
                Trace.WriteLine($"Unable to set direction {direction.ToString()} on com port {ComPortName} : {ex.Message}", Severity.Error);
            }
        }
Ejemplo n.º 26
0
        public CProgressBar(CProgressBar pb)
        {
            _PartyModeID = pb._PartyModeID;

            _TextureBackground    = pb.TextureBackground;
            _TextureForeground    = pb.TextureForeground;
            _TextureProgressLeft  = pb.TextureProgressLeft;
            _TextureProgressMid   = pb._TextureProgressMid;
            _TextureProgressRight = pb._TextureProgressRight;
            _AnimateMovement      = pb._AnimateMovement;
            _AnimateColoring      = pb._AnimateColoring;
            _Direction            = pb._Direction;
            _ProgressColors       = pb._ProgressColors;

            ColorBackground = pb.ColorBackground;
            ColorForeground = pb.ColorForeground;

            MaxRect          = pb.MaxRect;
            Reflection       = pb.Reflection;
            ReflectionSpace  = pb.ReflectionHeight;
            ReflectionHeight = pb.ReflectionSpace;

            AllMonitors = pb.AllMonitors;

            Alpha   = pb.Alpha;
            Visible = pb.Visible;

            _AnimTimer = new Stopwatch();
        }
Ejemplo n.º 27
0
        //=======================================================
        // Computation Functions
        //=======================================================

        protected Vector2 _GetNextTileVector(Vector2 i_CurrentTile, EDirection i_Direction)
        {
            /*
             * Return a new vector2 values according to relative direction of wizard
             * Return original vector2 values if the function failed to get.
             * Potential Error: Does not check on invalid index on map.
             */
            switch (i_Direction)
            {
            case EDirection.UP:
                i_CurrentTile.Y -= 1;
                return(i_CurrentTile);

            case EDirection.DOWN:
                i_CurrentTile.Y += 1;
                return(i_CurrentTile);

            case EDirection.LEFT:
                i_CurrentTile.X -= 1;
                return(i_CurrentTile);

            case EDirection.RIGHT:
                i_CurrentTile.X += 1;
                return(i_CurrentTile);
            }
            return(i_CurrentTile);
        }
Ejemplo n.º 28
0
        public bool Move(EDirection direction, bool[,] matrix)
        {
            var position = Position;

            switch (direction)
            {
            case EDirection.Left:
                position.X--;
                break;

            case EDirection.Right:
                position.X++;
                break;

            case EDirection.Down:
                position.Y++;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(direction), direction, null);
            }

            if (IsOccupied(position, matrix))
            {
                return(false);
            }

            Position = position;
            return(true);
        }
Ejemplo n.º 29
0
    //Returns the best hook (Collider2D) for a particular aiming direction
    public Collider2D getBestHook(EDirection aimDir)
    {
        Collider2D bestHook   = null;
        float      bestRating = 0;

        foreach (Collider2D currentHook in getHookables())
        {
            if (!currentHook) //make sure not null
            {
                continue;
            }

            if (hookObstructed(currentHook)) //make sure in line of sight
            {
                continue;
            }

            float currentRating = rateHook(currentHook, aimDir);
            if (currentRating > bestRating)
            {
                bestHook   = currentHook;
                bestRating = currentRating;
            }
        }
        return(bestHook);
    }
Ejemplo n.º 30
0
        /// <summary>
        /// Pinky tries to head for two tiles ahead of the player.
        /// </summary>
        void AttackAIPinky()
        {
            GridTile nextTile     = NextTile(player_.Direction, player_.Position);
            GridTile nextNextTile = NextTile(player_.Direction, new EntityPosition(nextTile.ToPoint, Point.Zero));

            direction_ = FindDirection(nextNextTile.ToPoint);
        }
Ejemplo n.º 31
0
        public void DoMove(EDirection direction)
        {
            int dimension = Dimension;

            switch (direction)
            {
            case EDirection.Left:
                m_Situation[m_IndexHole]     = m_Situation[m_IndexHole - 1];
                m_Situation[m_IndexHole - 1] = 0;
                m_IndexHole--;
                break;

            case EDirection.Right:
                m_Situation[m_IndexHole]     = m_Situation[m_IndexHole + 1];
                m_Situation[m_IndexHole + 1] = 0;
                m_IndexHole++;
                break;

            case EDirection.Up:
                m_Situation[m_IndexHole]             = m_Situation[m_IndexHole - dimension];
                m_Situation[m_IndexHole - dimension] = 0;
                m_IndexHole = m_IndexHole - dimension;
                break;

            case EDirection.Down:
                m_Situation[m_IndexHole]             = m_Situation[m_IndexHole + dimension];
                m_Situation[m_IndexHole + dimension] = 0;
                m_IndexHole = m_IndexHole + dimension;
                break;
            }
        }
Ejemplo n.º 32
0
    public virtual void SetCurrentDirection(EDirection dir)
    {
        switch (dir)
        {
        case EDirection.Left:
            CurrentDirection.x = -1;
            bShouldInvertX     = true;

            CharacterAnimator.SetAnimation(EAnimation.Move, bShouldInvertX, false);
            break;

        case EDirection.Right:
            CurrentDirection.x = 1;
            bShouldInvertX     = false;
            CharacterAnimator.SetAnimation(EAnimation.Move, bShouldInvertX, false);
            break;

        case EDirection.Up:
            break;

        case EDirection.Down:
            break;

        case EDirection.Neutral:
            CharacterAnimator.SetAnimation(EAnimation.Idle, bShouldInvertX, false);
            CurrentDirection.x = 0;
            break;
        }
    }
Ejemplo n.º 33
0
        private void Normalize(double Angle1, double Angle2, EDirection Direction)
        {
            double ra = (Math.Abs(m_RadiusX) + Math.Abs(m_RadiusY)) / 2;

            m_FlatenDeltaAngle = Math.Acos(ra / (ra + 0.125 / m_Scale)) * 2;
            if (Direction == EDirection.CounterClockWise)
            {
                while (Angle2 < Angle1)
                {
                    Angle2 += Math.PI * 2.0;
                }
            }
            else
            {
                while (Angle1 < Angle2)
                {
                    Angle1 += Math.PI * 2.0;
                }
                m_FlatenDeltaAngle = -m_FlatenDeltaAngle;
            }
            m_Direction     = Direction;
            m_StartAngle    = Angle1;
            m_EndAngle      = Angle2;
            m_IsInitialized = true;
        }
Ejemplo n.º 34
0
 public void ChangeDirection(EDirection direction)
 {
     this.SendCommand(new ChangeDirection()
     {
         Direction = (ECommandDirection?)direction
     });
 }
Ejemplo n.º 35
0
        private Boolean TryOpenDoor(GridSlot p_slot, EDirection p_dir)
        {
            List <InteractiveObject> doors = p_slot.GetDoors();

            for (Int32 i = 0; i < doors.Count; i++)
            {
                Door door = (Door)doors[i];
                if (door.Location == p_dir && door.State == EInteractiveObjectState.DOOR_CLOSED && door.Commands.Count > 0)
                {
                    door.Execute(LegacyLogic.Instance.MapLoader.Grid);
                    door.Update();
                    return(true);
                }
            }
            GridSlot neighborSlot = p_slot.GetNeighborSlot(LegacyLogic.Instance.MapLoader.Grid, p_dir);

            doors = neighborSlot.GetDoors();
            for (Int32 j = 0; j < doors.Count; j++)
            {
                Door door2 = (Door)doors[j];
                if (door2.Location == EDirectionFunctions.GetOppositeDir(p_dir) && door2.State == EInteractiveObjectState.DOOR_CLOSED && door2.Commands.Count > 0)
                {
                    door2.Execute(LegacyLogic.Instance.MapLoader.Grid);
                    door2.Update();
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 36
0
 public void SetNeighbour(Tile neighbour, EDirection direction)
 {
     if (neighbour != null)
     {
         int neighbourIndex = (int) direction;
         Neighbours[neighbourIndex] = neighbour;
     }
 }
 protected override void ReactToTileCollision(Tile tile, EDirection direction, Vector2 intersectionDepth)
 {
     if (tile.TileType == ETileType.SwitchMoveDirection && IsHeadingTowardsTile(tile) && Math.Abs(intersectionDepth.X) > tile.Dimensions.X/2)
     {
             ParentObject.Velocity = new Vector2(-ParentObject.Velocity.X, ParentObject.Velocity.Y);
     }
     base.ReactToTileCollision(tile, direction, intersectionDepth);
 }
Ejemplo n.º 38
0
		public Arc(double OriginX, double OriginY,
			 double RadiusX, double RadiusY,
			 double Angle1, double Angle2,
			 EDirection Direction = EDirection.CounterClockWise,
			 double Scale = 1.0,
			 bool moveToStart = true)
		{
			init(OriginX, OriginY, RadiusX, RadiusY, Angle1, Angle2, Direction: Direction, Scale: Scale, moveToStart: moveToStart);
		}
Ejemplo n.º 39
0
        protected override void ReactToTileCollision(Tile tile, EDirection direction, Vector2 intersectionDepth)
        {
            var cart = (ParentObject as Cart);

            if (tile.TileType == ETileType.TunnelEnd)
            {
                cart.State = EMachineState.Dead;
            }

            base.ReactToTileCollision(tile, direction, intersectionDepth);
        }
Ejemplo n.º 40
0
 public void init(double OriginX, double OriginY,
            double RadiusX, double RadiusY,
            double Angle1, double Angle2,
            EDirection Direction)
 {
     m_OriginX = OriginX;
     m_OriginY = OriginY;
     m_RadiusX = RadiusX;
     m_RadiusY = RadiusY;
     normalize(Angle1, Angle2, Direction);
 }
Ejemplo n.º 41
0
        public MainViewModel()
        {
            this.leftCommand = new ActionCommand(this.LeftCommandReq);
            this.rightCommand = new ActionCommand(this.RightCommandReq);
            this.upCommand = new ActionCommand(this.UpCommandReq);
            this.downCommand = new ActionCommand(this.DownCommandReq);

            this.width = 300;
            this.height = 300;

            this.currentDirection = EDirection.Right;
        }
Ejemplo n.º 42
0
 public Arc(double OriginX, double OriginY,
      double RadiusX, double RadiusY,
      double Angle1, double Angle2,
      EDirection Direction)
 {
     m_OriginX = OriginX;
     m_OriginY = OriginY;
     m_RadiusX = RadiusX;
     m_RadiusY = RadiusY;
     m_Scale = 1.0;
     normalize(Angle1, Angle2, Direction);
 }
Ejemplo n.º 43
0
        public bool Collides(IBlock block, IField field, EDirection direction)
        {
            bool collides = false;
            foreach (var position in block.Positions) {
                var newPosition = position.MoveOneStep(direction);
                collides = !staysWithinBorders(newPosition, field.Width, field.Height, direction) || field.FixedPositions.ContainsKey(newPosition);
                if (collides) {
                    return collides;
                }
            }

            return collides;
        }
Ejemplo n.º 44
0
 public static EDirection GetLeft(EDirection _Direction)
 {
     switch (_Direction) {
     case EDirection.left:
         return EDirection.down;
     case EDirection.right:
         return EDirection.up;
     case EDirection.up:
         return EDirection.left;
     case EDirection.down:
         return EDirection.right;
     }
     return EDirection.right;
 }
Ejemplo n.º 45
0
 private bool staysWithinBorders(Vector2 position, int width, int height, EDirection direction)
 {
     switch (direction) {
         case EDirection.Up:
             return position.Y >= 0;
         case EDirection.Down:
             return position.Y <= height - 1;
         case EDirection.Left:
             return position.X >= 0;
         case EDirection.Right:
             return position.X <= width -1;
         default:
             throw new ArgumentException(string.Format("{0} is not a valid direction", direction));
     }
 }
Ejemplo n.º 46
0
 public static Vector2 MoveOneStep(this Vector2 vector, EDirection direction)
 {
     switch (direction) {
         case EDirection.Up:
             return vector + new Vector2(0, -1);
         case EDirection.Down:
             return vector + new Vector2(0, 1);
         case EDirection.Left:
             return vector + new Vector2(-1, 0);
         case EDirection.Right:
             return vector + new Vector2(1, 0);
         default:
             throw new ArgumentException(string.Format("{0} is not a valid direction", direction));
     }
 }
Ejemplo n.º 47
0
		public void init(double OriginX, double OriginY,
				   double RadiusX, double RadiusY,
				   double Angle1, double Angle2,
				   EDirection Direction = EDirection.CounterClockWise,
				   double Scale = 1.0,
				   bool moveToStart = true)
		{
			originX = OriginX;
			originY = OriginY;
			radiusX = RadiusX;
			radiusY = RadiusY;
			m_Scale = Scale;
			this.moveToStart = moveToStart;
			normalize(Angle1, Angle2, Direction);
		}
Ejemplo n.º 48
0
        /// <summary>
        /// Sprawdza z której strony nastąpiła kolizja
        /// </summary>
        /// <param name="collisionDepth">Głębokość kolizji</param>
        /// <param name="direction">Kierunek - pion lub poziom</param>
        /// <returns></returns>
        public static ESide GetCollisionOrigin(Vector2 collisionDepth, EDirection direction)
        {
            ESide side = ESide.NotAssigned;

            if (direction==EDirection.Vertical)
            {
                if (collisionDepth.Y < 0) side = side | ESide.Top;
                else if (collisionDepth.Y > 0) side = side | ESide.Bottom;
            }
            else
            {
                if (collisionDepth.X < 0) side = side | ESide.Left;
                else if (collisionDepth.Y > 0) side = side | ESide.Right;
            }
            return side;
        }
Ejemplo n.º 49
0
 public void Move(EDirection _Dir)
 {
     switch (_Dir)
     {
         case EDirection.left:
             SetPos(m_iCol-1, m_iRow);
             break;
         case EDirection.right:
             SetPos(m_iCol+1, m_iRow);
             break;
         case EDirection.up:
             SetPos(m_iCol, m_iRow+1);
             break;
         case EDirection.down:
             SetPos(m_iCol, m_iRow-1);
             break;
     }
 }
Ejemplo n.º 50
0
 //Рухаємо змію. Якщо вона себе кусає, повертаємо true;
 public bool Move(EDirection direction, out List<Visualizer.Terrain> coordsToRepaint)
 {
     coordsToRepaint = new List<Visualizer.Terrain> { new Visualizer.Terrain(Visualizer.TerrainInfo.Backcolor, _snake.Peek()),
                                                      new Visualizer.Terrain(Visualizer.TerrainInfo.Snake, _head) };
     var s = _head + _dictionary[direction];
     if (_snake.Contains(s) || _head.X <= 0 || _head.X >= _size.Width - 1 || _head.Y <= 0 || _head.Y >= _size.Height - 1)
         return true;
     _head = s;
     _snake.Enqueue(_head);
     coordsToRepaint.Add(new Visualizer.Terrain(Visualizer.TerrainInfo.Head, _head));
     if (_head == Food) //Якщо змійка потрапила на клітинку з їжею, ми заповнюемо випадкову клітинку їжею.
     {
         Score += ScoreForFood;
         PlaceFood();
     }
     else _snake.Dequeue(); //Інакше, щоб змія не збільшилась, прибираемо останній сегмент
     coordsToRepaint.Add(new Visualizer.Terrain(Visualizer.TerrainInfo.Food, Food));
     return false; //Ми себе не вкусили, значить false
 }
Ejemplo n.º 51
0
 // reads key and returns object based on key, object is handled by game manager
 internal Object PollKey(EDirection currentDirection) {
     if (!Console.KeyAvailable) return null;
     var cki = Console.ReadKey(true);
     switch (cki.Key){
         case ConsoleKey.Escape:
             return cki;
         case ConsoleKey.Spacebar:
             return cki;
         default:
             if (cki.Key == ConsoleKey.UpArrow && currentDirection != EDirection.South)
                 return EDirection.North;
             if (cki.Key == ConsoleKey.RightArrow && currentDirection != EDirection.West)
                 return EDirection.East;
             if (cki.Key == ConsoleKey.DownArrow && currentDirection != EDirection.North)
                 return EDirection.South;
             if (cki.Key == ConsoleKey.LeftArrow && currentDirection != EDirection.East)
                 return EDirection.West;
             return null;
     }
 }
Ejemplo n.º 52
0
    void Update()
    {
		if (GetComponentInParent<GestureScript>().GestureStart("Forward"))
        {
            Direction = EDirection.Up;
        }
		else if (GetComponentInParent<GestureScript>().GestureStart("Middle"))
        {
            Direction = EDirection.Left;
        }
		else if (GetComponentInParent<GestureScript>().GestureStart("Wide"))
        {
            Direction = EDirection.Right;
        }
		else if (GetComponentInParent<GestureScript>().GestureStart("Down"))
        {
            Direction = EDirection.Forward;
        }

        UpdateRotation();
    }
Ejemplo n.º 53
0
        protected override void ReactToTileCollision(Tile tile, EDirection direction, Vector2 intersectionDepth)
        {
            var player = (ParentObject as Player);

            if (direction == EDirection.Vertical && player.Velocity.Y > player.MinDeathSpeed &&
                (tile.CollisionType == ETileCollisionType.Platform || tile.CollisionType == ETileCollisionType.Impassable))
            {
                player.OnDied();
            }

            player.IsCollidingWithLadder = false;
            if (tile.TileType == ETileType.LadderMiddle || tile.TileType==ETileType.LadderTop)
            {
                player.IsCollidingWithLadder = true;
            }

            if ((tile.TileType == ETileType.LadderTop && player.IsClimbing))
            {
                return;
            }

            base.ReactToTileCollision(tile, direction, intersectionDepth);
        }
Ejemplo n.º 54
0
 protected abstract void SetPressedGraphics(EDirection dir, bool pressed);
Ejemplo n.º 55
0
    // sets the pressed state for a direction, which includes both
    // the data state and the graphical state.
    protected virtual void SetPressed(EDirection dir, bool pressed)
    {
        // do nothing if setting to the same value
        if (Pressed(dir) == pressed)
            return;

        SetBitfield(dir, pressed);

        SetPressedGraphics(dir, pressed);
    }
Ejemplo n.º 56
0
    // sets the bitfield's pressed state for the specified direction
    protected void SetBitfield(EDirection dir, bool pressed)
    {
        // clear the bit
        _pressedField &= ~((int)dir);

        if (pressed)
        {
            // set it
            _pressedField |= (int)dir;
        }
    }
Ejemplo n.º 57
0
    // utility to get the opposite direction of a specified direction
    protected EDirection GetOpposite(EDirection dir)
    {
        switch (dir)
        {
            case EDirection.Up: return EDirection.Down;
            case EDirection.Down: return EDirection.Up;
            case EDirection.Left: return EDirection.Right;
            case EDirection.Right: return EDirection.Left;
        }

        return EDirection.None;
    }
Ejemplo n.º 58
0
 /// <summary>
 /// Returns true if the specified EDirection is currently pressed, otherwise, false.
 /// </summary>
 public bool Pressed(EDirection dir)
 {
     return (_pressedField & (int)dir) != 0;
 }
Ejemplo n.º 59
0
    protected override void SetPressedGraphics(EDirection dir, bool pressed)
    {
        // only change pressed state if we're in joystick mode (and thus collision detection is off).
        // otherwise, the buttons handle the pressed graphics state themselves (during their collision detection).
        if (!JoystickMode)
            return;

        if (dir == EDirection.Left && LeftButton != null)
            LeftButton.ForcePressed = pressed;

        if (dir == EDirection.Right && RightButton != null)
            RightButton.ForcePressed = pressed;

        if (dir == EDirection.Up && UpButton != null)
            UpButton.ForcePressed = pressed;

        if (dir == EDirection.Down && DownButton != null)
            DownButton.ForcePressed = pressed;
    }
Ejemplo n.º 60
0
    public void SetDirection(EDirection i_eNewDirection)
    {
        m_eMovementDirection = i_eNewDirection;

        if (animator)
        {
            // Set the animation
            switch (GetDirection ())
            {
            case EDirection.DOWN:
                animator.SetInteger("Direction", 0);
                break;
            case EDirection.LEFT:
                animator.SetInteger("Direction", 1);
                break;
            case EDirection.UP:
                animator.SetInteger("Direction", 2);
                break;
            case EDirection.RIGHT:
                animator.SetInteger("Direction", 3);
                break;
            }
        }
    }