示例#1
0
    private void FixedUpdate()
    {
    #if UNITY_EDITOR
        if (grounded)
        {
            movePlayer(new Vector2(Input.GetAxis("Horizontal"), 0));
        }
    #endif

        if (grounded)
        {
            if (moveType.Equals(MoveType.None))
            {
                movePlayer(new Vector2(0f, 0f));
            }
            else if (moveType.Equals(MoveType.Left))
            {
                movePlayer(new Vector2(-1.0f, 0f));
            }
            else if (moveType.Equals(MoveType.Right))
            {
                movePlayer(new Vector2(1.0f, 0f));
            }
        }
    }
    void MovePlatform(Vector3 movement)
    {
        float dist = Vector3.Distance(m_des, transform.position);

        //Debug.Log("Distance to other: " + moveType + " " + dist);
        //Debug.Log("m_des: " + m_des);
        //Debug.Log("m_transform: " + transform.position);
        //if (dist > distance)
        if (dist > distance)
        {
            //Debug.Log(destination);
            Vector2 currentPosition = platformRigidbody.position;
            //platformRigidbody.MovePosition(currentPosition + movement);
            platformRigidbody.transform.position += movement;
        }
        else
        {
            if (moveType.Equals(MoveType.OneWay))
            {
                CanMove = false;
            }
            else if (moveType.Equals(MoveType.Infinite))
            {
                SwapDestination(ref m_des, ref m_des2);
                velocity *= -1;
            }
        }
    }
示例#3
0
    public void SetMovement(Vector2 startPosition, Vector2[] _targets, float _speed, float _timeToWait, float _timeToKillBubble)
    {
        if (!initialized || moveType.Equals(MoveType.Direction) || moveType.Equals(MoveType.Target))
        {
            Debug.LogError("Attack was not initialized correctly");
            return;
        }

        timetoKillBubble   = _timeToKillBubble;
        targets            = _targets;
        speed              = _speed;
        transform.position = startPosition;

        StartCoroutine(WaitToMove(_timeToWait));
    }
 public static bool IsValidMove(MoveType type, FieldValue color, Coords coords, IBoardReader board)
 {
     if (type.Equals(MoveType.AddPiece))
     {
         return(IsValidMove(color, coords, board));
     }
     else if (type.Equals(MoveType.Pass))
     {
         return(!GetValidMovesForColor(color, board).Any());
     }
     else
     {
         return(false);
     }
 }
 public static bool IsValidMove(MoveType type, FieldValue color, Coords coords, IBoardReader board)
 {
     if (type.Equals(MoveType.AddPiece))
     {
         return IsValidMove(color, coords, board);
     }
     else if (type.Equals(MoveType.Pass))
     {
         return !GetValidMovesForColor(color, board).Any();
     }
     else
     {
         return false;
     }
 }
示例#6
0
    void CalculateCollision()
    {
        Vector3 hitSize = Vector3.one * 0.5f;

        if (moveType.Equals(MoveType.Horizontal))
        {
            int coord = 1 * direction;
            if (!Physics2D.OverlapBox(movePoint.position + new Vector3(coord, 0f, 0f), hitSize, 0, obstacleMask))
            {
                movePoint.position += new Vector3(coord, 0f, 0f);
                //    sprite.localScale = new Vector2(flipX * coord, sprite.localScale.y);
                mover.MoveTo(movePoint.position);
            }
            else
            {
                direction *= -1;
            }
        }
        else
        {
            int coord = 1 * direction;
            if (!Physics2D.OverlapBox(movePoint.position + new Vector3(0f, coord, 0f), hitSize, 0, obstacleMask))
            {
                movePoint.position += new Vector3(0f, coord, 0f);
                mover.MoveTo(movePoint.position);
            }
            else
            {
                direction *= -1;
            }
        }
    }
示例#7
0
        protected bool Equals(BoardMove other)
        {
            return(Equals(From, other.From) &&
                   Equals(To, other.To) &&
                   MoveType.Equals(other.MoveType)
//                   && (
//                       MoveType != MoveType.PawnPromotion
//                       || Equals(ExtraData, other.ExtraData)
//                       )
                   );
        }
示例#8
0
    public void SetMovement(Vector2 startPosition, int _direction, int _yAxis, float _speed)
    {
        if (!initialized || moveType.Equals(MoveType.Target))
        {
            Debug.LogError("Attack was not initialized correctly");
            return;
        }

        direction = _direction;
        speed     = _speed;
        isMoving  = true;

        transform.position = new Vector2(startPosition.x + (direction * 0.0001f), startPosition.y);

        if (direction == -1)
        {
            transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z);
        }

        if (_yAxis == -1)
        {
            transform.localScale = new Vector3(transform.localScale.x, -transform.localScale.y, transform.localScale.z);
        }
    }
        public bool MakeMove(MoveType type, Coords coords)
        {
            if (OthelloRules.IsValidMove(type, m_activePlayer.Color, coords, m_board))
            {
                if (type.Equals(MoveType.AddPiece))
                {
                    FieldValue color = m_activePlayer.Color;

                    var flipDirections = OthelloRules.GetPossibleDirections(color, coords, m_board);
                    foreach (var dir in flipDirections)
                    {
                        FlipDirection(color, coords, dir);
                    }
                    m_board.SetFieldValue(color, coords);
                }

                ToggleActivePlayer();
                return true;
            }

            return false;
        }
示例#10
0
        public bool MakeMove(MoveType type, Coords coords)
        {
            if (OthelloRules.IsValidMove(type, m_activePlayer.Color, coords, m_board))
            {
                if (type.Equals(MoveType.AddPiece))
                {
                    FieldValue color = m_activePlayer.Color;

                    var flipDirections = OthelloRules.GetPossibleDirections(color, coords, m_board);
                    foreach (var dir in flipDirections)
                    {
                        FlipDirection(color, coords, dir);
                    }
                    m_board.SetFieldValue(color, coords);
                }

                ToggleActivePlayer();
                return(true);
            }

            return(false);
        }
示例#11
0
文件: Move.cs 项目: madddmax/jackal
 public bool Equals(Move other)
 {
     return(base.Equals(other) && Type.Equals(other.Type));
 }
        private void MovHandler()
        {
            PrepareOperands(CurrentCommand.Replace("MOV", ""));
            var operandsPair = CurrentArithmeticCmd;

            if (toVar.Equals(MoveType.Null))
            {
                switch (currentMoveType)
                {
                case MoveType.VarToRegister:
                case MoveType.NumValueToRegister:
                case MoveType.CharValueToRegister:
                    UI.AX = operandsPair.Key.Equals("AX") ? operandsPair.Value : UI.AX;
                    UI.BX = operandsPair.Key.Equals("AX") ? UI.BX : operandsPair.Value;
                    break;
                }
            }
            else
            {
                switch (toVar)
                {
                case MoveType.RegisterToVar:
                case MoveType.NumValueToVar:
                    if (Ints.FirstOrDefault(Int => Int.Name == operandsPair.Key) != null)
                    {
                        var temp = Ints.First(Int => Int.Name == operandsPair.Key);
                        if (temp.Type.Contains("RES"))
                        {
                            temp.Value = 0;
                            temp.Type  = "DW";
                        }
                        temp.Value = operandsPair.Value;
                        EmuVar <int> mem = VarsInMemory.First(var => var.Name == temp.Name);
                        MemoryMapHandler(mem.MemoryIndex, temp.Value);
                        View.MemoryStructure.Items.Refresh();
                        Ints.Remove(Ints.First(Int => Int.Name == operandsPair.Key));
                        Ints.Add(temp);
                    }
                    if (Floats.FirstOrDefault(Float => Float.Name == operandsPair.Key) != null)
                    {
                        var temp = Floats.First(Float => Float.Name == operandsPair.Key);
                        if (temp.Type.Contains("RES"))
                        {
                            temp.Value = 0;
                            temp.Type  = "DD";
                        }
                        temp.Value = operandsPair.Value;
                        Floats.Remove(Floats.First(Float => Float.Name == operandsPair.Key));
                        Floats.Add(temp);
                    }
                    break;

                case MoveType.CharValueToVar:
                    if (Chars.FirstOrDefault(Char => Char.Name == operandsPair.Key) != null)
                    {
                        var temp = Chars.First(Chars => Chars.Name == operandsPair.Key);
                        if (temp.Type.Contains("RES"))
                        {
                            temp.Value = (char)0;
                            temp.Type  = "DB";
                        }
                        temp.Value = (char)operandsPair.Value;
                        Chars.Remove(Chars.First(Char => Char.Name == operandsPair.Key));
                        Chars.Add(temp);
                    }
                    break;
                }
            }
            IncreaseIndex();
        }