示例#1
0
        public void AddChildren(MatrixNode node)
        {
            string opposite;

            if (node.Moves.Count > 0)
            {
                opposite = Movable.CalcOposite(node.Moves.Last());
            }
            else
            {
                opposite = "";
            }
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    Movable aux = MovesFactory.GetInstance(i, j);
                    if (aux.IsValid(node.Matrix))
                    {
                        if (!opposite.Equals(aux.GetString()))
                        {
                            string[,] movedMatrix = aux.Move(node.Matrix);
                            MatrixNode child = new MatrixNode(movedMatrix, FinishMatrix);
                            child.Sucesors.AddRange(node.Sucesors);
                            child.Sucesors.Add(child);
                            child.Moves.AddRange(node.Moves);
                            child.Moves.Add(aux);
                            child.calculateEvaluationFunction();
                            AddInOrder(child);
                        }
                    }
                }
            }
        }
示例#2
0
 public override bool MoveTo(Movable movable, int direction)
 {
     if (Movable != null)
     {
         if (Movable.Move(direction))
         {
             Movable = movable;
             _timesWalkedOver++;
             return(true);
         }
         else
         {
             return(false);
         }
     }
     //Type check
     if ((movable is Crate) && _timesWalkedOver >= 3)
     {
         Movable = null;
         return(true);
     }
     Movable = movable;
     _timesWalkedOver++;
     return(true);
 }
示例#3
0
 public override bool MoveTo(Movable movable, int direction)
 {
     //Type check
     if (movable is Crate)
     {
         if (Movable != null)
         {
             return(false);
         }
     }
     //Type check
     if (Movable is Sleeper)
     {
         return(false);
     }
     if (Movable != null)
     {
         if (Movable.Move(direction))
         {
             Movable = movable;
             return(true);
         }
         return(false);
     }
     Movable = movable;
     return(true);
 }
示例#4
0
    void MoveComplete(Movable movable)
    {
        if (movable != this.movable)
        {
            return;
        }

        if (stops.Count == 0)
        {
            Dispose();
        }
        else
        {
            Cell stop = stops[0];
            stops.RemoveAt(0);
            Cell start = movable.Cell;

            int startIndex = path.Cells.IndexOf(start);
            if (startIndex != -1)
            {
                foreach (Farmer f in start.Inventory.Farmers)
                {
                    foreach (Pair <Farmer, Cell> farmer in farmers)
                    {
                        if (farmer.First == f)
                        {
                            int stopInd = -1;
                            if (farmer.Second != null)
                            {
                                stopInd = path.Cells.IndexOf(farmer.Second);
                            }

                            if (stopInd == -1)
                            {
                                stopInd = path.Cells.Count - 1;
                            }

                            List <Cell> subpathFarmer = path.Cells.GetRange(startIndex, stopInd - startIndex + 1);
                            f.Move(subpathFarmer);
                            break;
                        }
                    }
                }

                int stopIndex = path.Cells.IndexOf(stop, startIndex + 1);
                if (stopIndex != -1)
                {
                    List <Cell> subpathHero = path.Cells.GetRange(startIndex, stopIndex - startIndex + 1);
                    movable.Move(subpathHero, totalFreeMoves);
                }
                else
                {
                    Dispose();
                }
            }
        }
    }
示例#5
0
        public void Move(string id, Vector2 position, int time = 0)
        {
            GameObject go = GameObject.Find(id);
            Movable    m  = go.GetComponent <Movable>();

            if (m != null)
            {
                m.Move(position);
            }
        }
示例#6
0
 public override bool MoveTo(Movable movable, int direction)
 {
     if (Movable != null)
     {
         Movable.Move(direction);
         Movable = movable;
         return(true);
     }
     Movable = movable;
     return(true);
 }
示例#7
0
        public void SingleCommand_Execution(double currentX, double currentY, Direction currentDirection, Command command, double newX, double newY, Direction newDirection)
        {
            var direction = GetDirection(currentDirection);

            marsRover = new Rover(currentX, currentY, direction);

            marsRover.Move(command);

            Assert.Equal(newDirection, marsRover.Direction.Name);
            Assert.Equal(newX, marsRover.Position.X);
            Assert.Equal(newY, marsRover.Position.Y);
        }
        public void Move_WithVelocity_ChangePosition()
        {
            var      moveSettings = Resources.Load <MovementSettings>("Settings/PlayerShip");
            IMovable movable      = new Movable(moveSettings);

            movable.Position = Vector3.zero;
            movable.Velocity = new Vector3(1.0f, 0.0f, 0.0f);

            movable.Move(1.0f);
            var actual = movable.Position;

            Assert.AreEqual(new Vector3(1.0f, 0.0f, 0.0f), actual);
        }
示例#9
0
    void Update()
    {
        if (Input.GetKey(keyUp))
        {
            Mover.Move(MoveDir.Forward);
        }
        else if (Input.GetKey(keyDown))
        {
            Mover.Move(MoveDir.Backward);
        }

        if (Input.GetKey(keyLeft) && Input.GetKey(keyRight))
        {
        }
        else if (Input.GetKey(keyLeft))
        {
            Mover.Turn(TurnDir.CcwLeft);
        }
        else if (Input.GetKey(keyRight))
        {
            Mover.Turn(TurnDir.CwRight);
        }
    }
示例#10
0
    /// <summary>
    /// This will apply physics to the object
    /// It will always be called from WorldManager FixedUpdate
    /// Therefore it should be treated as a FixedUpdate function
    /// </summary>
    public Movable.MoveResult Move(PlayerController.Direction Dir)
    {
        Movable.MoveResult Result = Movable.MoveResult.CannotMove;
        // move
        Movable Mover = GetComponent <Movable>();

        if (Mover)
        {
            Result = Mover.Move(Mdl.CurrentDirection, true, true);
            checkSpriteFlip(Dir);
        }
        Tails.Tick();
        return(Result);
    }
示例#11
0
    public void PullEvent(InputAction.CallbackContext context)
    {
        if (selectedMovable)
        {
            selectedMovable.Move(transform.position, true);
            //RemoveCable();
        }
        else
        {
            if (cableEnabled)
            {
                isPulling   = true;
                isReleasing = false;


                pullSFX.Play();
            }
            else
            {
                AirBoost();
            }
        }
    }
示例#12
0
 public override void OnFixedTick()
 {
     if (!WM)
     {
         FindWM();
     }
     if (WM.TL.Mode == InputManager.Mode.REPLAY)
     {
         base.OnFixedTick();
     }
     if (WM.TL.Mode == InputManager.Mode.RECORD)
     {
         _go?.Move(_dir, true, true, this);
     }
 }
示例#13
0
    public void Update()
    {
        Vector2 inputDir = GetMoveDir();

        fallSpeed = mover.IsGrounded ? 0 : fallSpeed - (Physics.gravity.y * Time.deltaTime);
        mover.Move(GetVelocity(inputDir, fallSpeed) * Time.deltaTime);

        Vector2 inputRot = GetRotDir();

        if (inputRot != Vector2.zero)
        {
            float target = CalculateFaceAngle(inputRot);
            Turn(target);
        }
    }
示例#14
0
    // Update is called once per frame
    void Update()
    {
        if (r.NextDouble() <= .8)        // 80% of time - move, 20% - do nothing
        {
            if (r.NextDouble() <= .80)   // 80% - move forward, 15% - move bw, 5% dont move
            {
                Mover.Move(MoveDir.Forward);
            }
            else if (r.NextDouble() <= .75)
            {
                Mover.Move(MoveDir.Backward);
            }
        }

        if (r.NextDouble() < .3)     // 30% of time turn somewhere, 70% dont turn
        {
            if (r.NextDouble() < .1) // in rare case (10%) change direction, 90% - keep previous
            {
                dir = dir == TurnDir.CcwLeft ? TurnDir.CwRight : TurnDir.CcwLeft;
            }

            Mover.Turn(dir);
        }
    }
示例#15
0
    public override void _Process(float delta)
    {
        // refresh words timer
        if (refreshTimer > 0)
        {
            refreshTimer -= delta;

            if (refreshTimer <= 0)
            {
                RefreshWords();
                refreshWords = false;
                refreshTimer = 0;
            }
        }

        // controls
        int horizontal = 0;
        int vertical   = 0;

        horizontal += Input.IsActionPressed("ui_right") ? 1 : 0;
        horizontal -= Input.IsActionPressed("ui_left") ? 1 : 0;
        vertical   -= Input.IsActionPressed("ui_up") ? 1 : 0;
        vertical   += Input.IsActionPressed("ui_down") ? 1 : 0;

        var  movement = new Vector2(vertical == 0 ? horizontal : 0, vertical) * gridBlockSize;
        bool isMoving = false;

        if (movement != Vector2.Zero)
        {
            var list = GetTree().GetNodesInGroup(G_CONTROLLABLE);
            for (int i = 0; i < list.Count; i++)
            {
                Movable m = (Movable)list[i];
                isMoving = m.Move(movement, tickTime);
            }

            if (isMoving)
            {
                Tick();
            }
        }
        else if (Input.IsActionJustReleased("wait"))
        {
            Tick();
        }
    }
示例#16
0
 /// <summary>
 /// Attacks the target. If the target is not in stopping range, chases it. If the target is near
 /// performs a hit on it. If currently performing a hit, waits for finishing the hit and deals
 /// damage if hit was successful. Either resets afterwards or continues chasing / attacking target.
 /// </summary>
 private void Attack()
 {
     _distanceToTarget = Vector3.Distance(_target.transform.position, transform.position);
     if (_distanceToTarget < attackRange - stoppingOffset && Status == AttackStatus.None ||
         Status == AttackStatus.TargetReached)
     {
         IsInRange();
     }
     else if (Status == AttackStatus.NotFinished)
     {
         Status = PerformHit();
         if (Status != AttackStatus.NotFinished)
         {
             HitFinished();
         }
     }
     else
     {
         // chase target
         _movable.Move(_target.transform.position);
     }
 }
示例#17
0
    void Update()
    {
        // Test for clicks
        if (Input.GetButtonDown("Move"))
        {
            RaycastHit hitInfo;

            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo, Mathf.Infinity, Layers.Map))
            {
                // Spawn a marker
                if (!tempCircle)
                {
                    tempCircle = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                }

                tempCircle.transform.position   = hitInfo.point;
                tempCircle.transform.localScale = new Vector3(10, 10, 10);

                // Move the unit to the point
                Selector selectGroup = transform.root.GetComponent <Selector>();

                if (selectGroup)
                {
                    foreach (Selectable unit in selectGroup.SelectedUnits)
                    {
                        Loyal       loyalty = unit.GetComponent <Loyal>();
                        Influential queen   = unit.GetComponent <Influential>();
                        Movable     action  = unit.GetComponent <Movable>();

                        if (action && ((loyalty && loyalty.allegiance == player.queen) || (queen && queen == player.queen)))
                        {
                            action.Move(hitInfo.point);
                        }
                    }
                }
            }
        }
    }
示例#18
0
    // Update is called once per frame
    void Update()
    {
        move = 0;
        if (!gameManager.isGameOver)
        {
            if (gameManager.view == View.ThirdPerson)
            {
                move = Input.GetAxis("Horizontal");
            }
            else
            {
                move = Input.GetAxis("Vertical");
                if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.A))
                {
                    movable.Rotate(-1);
                }
                else if (Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.D))
                {
                    movable.Rotate(1);
                }
            }

            /*if (Input.GetKey(KeyCode.LeftShift))
             * {
             *  move *= RunSpeed;
             * }
             * else
             * {
             *  move *= WalkSpeed;
             * }*/
            move *= WalkSpeed;
            if (Input.GetButtonDown("Jump"))
            {
                movable.Jump(JumpForce);
            }
        }
        movable.Move(move);
    }
 private void FixedUpdate()
 {
     movableComponent.MoveDirection = new Vector3(xInput, 0, zInput);
     movableComponent.Move();
 }
示例#20
0
        static void Main(string[] args)
        {
            Console.WriteLine("Produced by Raufat and Diyaz for SIS 2");
            Console.WriteLine("WELCOME TO THE MOST EXTREME RACING EVER!!!");
            Console.WriteLine("Please select a game mode"); // Classic or Heavinly
            string choice = Console.ReadLine();

            if (choice.Equals("Classic"))
            {
                Console.WriteLine("Enter your name");
                Game game = new Game(User.Player.name, new ClassicRacing(), new ClassicRacing());
                Console.WriteLine("Enter name of car");
                string NameOfCar = Console.ReadLine();
                Console.WriteLine("Do you want to mofidy the car?");
                string answer = Console.ReadLine();
                if (answer.Equals("Yes"))
                {
                    Console.WriteLine("Select a car"); //JustCar or SportCar
                    string answer2 = Console.ReadLine();
                    if (answer2.Equals("Just car"))
                    {
                        Car car = new JustCar(NameOfCar);
                        Console.WriteLine("Do you want to change a color of car?");
                        string answer3 = Console.ReadLine();
                        if (answer3.Equals("No"))
                        {
                        }
                        if (answer3.Equals("Yes"))
                        {
                            car = new TunedCar(car);
                            car.ChooseColour();
                            car.Painting();
                        }
                        Console.WriteLine("Do you want to put a new engine?");
                        string answer4 = Console.ReadLine();
                        if (answer4.Equals("Yes"))
                        {
                            car = new UpgradedCar(car);
                            car.PutNewEngine();
                            car.PrintCharacteristics();
                        }
                        if (answer4.Equals("No"))
                        {
                            car.PrintCharacteristics();
                        }
                    }
                    if (answer2.Equals("Sport car"))
                    {
                        Car car = new SportCar(NameOfCar);
                        Console.WriteLine("Do you want to change a color of car?");
                        string answer3 = Console.ReadLine();
                        if (answer3.Equals("No"))
                        {
                        }
                        if (answer3.Equals("Yes"))
                        {
                            car = new TunedCar(car);
                            car.ChooseColour();
                            car.Painting();
                            car.PrintCharacteristics();
                        }
                        Console.WriteLine("Do you want to put a new engine?");
                        string answer4 = Console.ReadLine();
                        if (answer4.Equals("Yes"))
                        {
                            car = new UpgradedCar(car);
                            car.PutNewEngine();
                            car.PrintCharacteristics();
                        }
                        if (answer4.Equals("No"))
                        {
                            car.PrintCharacteristics();
                        }
                    }
                }
                else
                {
                    Car car = new JustCar(NameOfCar);
                    car.PrintCharacteristics();
                }

                Console.WriteLine("Select the difficulty level of the game");
                string level = Console.ReadLine(); // easy, middle, hard
                if (level.Equals("Easy"))
                {
                    DifficultyLevel dif  = new Easy(level);
                    Bots            bots = dif.Create();
                }
                if (level.Equals("Middle"))
                {
                    DifficultyLevel dif  = new Middle(level);
                    Bots            bots = dif.Create();
                }
                if (level.Equals("Hard"))
                {
                    DifficultyLevel dif  = new Hard(level);
                    Bots            bots = dif.Create();
                }

                Console.WriteLine("Please, wait, game is about to start");
                game.Start();
                Movable mova     = new Movable(); // observer
                Car     observer = new Car(NameOfCar, mova);
                mova.RoadHazards();
                Movable mov = new Movable(new Forward());
                mov.Move();
                while (true)
                {
                    string moving = Console.ReadLine();
                    if (moving.Equals("Left"))
                    {
                        Movable mov1 = new Movable(new ToTheLeft());
                        mov1.Move();
                    }
                    if (moving.Equals("Right"))
                    {
                        Movable mov2 = new Movable(new ToTheRight());
                        mov2.Move();
                    }
                    if (moving.Equals("Forward"))
                    {
                        Movable mov3 = new Movable(new Forward());
                        mov3.Move();
                    }
                    if (moving.Equals("Stop"))
                    {
                        Movable mov4 = new Movable(new Stop());
                        mov4.Move();
                        Console.WriteLine("Do you want to finish game?");
                        string finish = Console.ReadLine();
                        if (finish.Equals("Yes"))
                        {
                            game.Finish();
                        }
                    }
                }
            }
            if (choice.Equals("Heavenly")) // небесный режим
            {
                Console.WriteLine("Enter your name");
                Game game = new Game(User.Player.name, new HeavinlyRacing(), new HeavinlyRacing());
                Console.WriteLine("Enter name of Flycar");
                string NameOfCar = Console.ReadLine();
                Console.WriteLine("Do you want to mofidy your Flycar?");
                string answer = Console.ReadLine();
                if (answer.Equals("Yes"))
                {
                    Console.WriteLine("Select a car"); //FlyCar or Rocket
                    string answer2 = Console.ReadLine();
                    if (answer2.Equals("FlyCar"))
                    {
                        Car car = new JustCar(NameOfCar);
                        Console.WriteLine("Do you want to change a color of yout Flycar?");
                        string answer3 = Console.ReadLine();
                        if (answer3.Equals("No"))
                        {
                        }
                        if (answer3.Equals("Yes"))
                        {
                            car = new TunedFlyCar(car);
                            car.ChooseColour();
                            car.Painting();
                        }
                        Console.WriteLine("Do you want to put a new engine?");
                        string answer4 = Console.ReadLine();
                        if (answer4.Equals("Yes"))
                        {
                            car = new UpgradedFlyCar(car);
                            car.PutNewEngine();
                            car.PrintCharacteristics();
                        }
                        if (answer4.Equals("No"))
                        {
                            car.PrintCharacteristics();
                        }
                    }
                    if (answer2.Equals("Rocket"))
                    {
                        Car car = new Raket(NameOfCar);
                        Console.WriteLine("Do you want to change a color of your Fly transport?");
                        string answer3 = Console.ReadLine();
                        if (answer3.Equals("No"))
                        {
                        }
                        if (answer3.Equals("Yes"))
                        {
                            car = new TunedFlyCar(car);
                            car.ChooseColour();
                            car.Painting();
                            car.PrintCharacteristics();
                        }
                        Console.WriteLine("Do you want to put a new engine?");
                        string answer4 = Console.ReadLine();
                        if (answer4.Equals("Yes"))
                        {
                            car = new UpgradedFlyCar(car);
                            car.PutNewEngine();
                            car.PrintCharacteristics();
                        }
                        if (answer4.Equals("No"))
                        {
                            car.PrintCharacteristics();
                        }
                    }
                }
                else
                {
                    Car car = new FlyCar(NameOfCar);
                    car.PrintCharacteristics();
                }

                Console.WriteLine("Select the difficulty level of the game");
                string level = Console.ReadLine(); // easy, middle, hard
                if (level.Equals("Easy"))
                {
                    DifficultyLevel dif  = new Easy(level);
                    Bots            bots = dif.Create();
                }
                if (level.Equals("Middle"))
                {
                    DifficultyLevel dif  = new Middle(level);
                    Bots            bots = dif.Create();
                }
                if (level.Equals("Hard"))
                {
                    DifficultyLevel dif  = new Hard(level);
                    Bots            bots = dif.Create();
                }

                Console.WriteLine("Please, wait, game is about to start");
                game.Start();
                Movable mova     = new Movable(); // observer
                Car     observer = new Car(NameOfCar, mova);
                mova.RoadHazards();
                Movable mov = new Movable(new Forward());
                mov.Move();
                while (true)
                {
                    string moving = Console.ReadLine();
                    if (moving.Equals("Left"))
                    {
                        Movable mov1 = new Movable(new ToTheLeft());
                        mov1.Move();
                    }
                    if (moving.Equals("Right"))
                    {
                        Movable mov2 = new Movable(new ToTheRight());
                        mov2.Move();
                    }
                    if (moving.Equals("Forward"))
                    {
                        Movable mov3 = new Movable(new Forward());
                        mov3.Move();
                    }
                    if (moving.Equals("Nitro"))
                    {
                        Movable mov4 = new Movable(new Nitro());
                        mov4.Move();
                    }
                    if (moving.Equals("Stop"))
                    {
                        Movable mov4 = new Movable(new Stop());
                        mov4.Move();
                        Console.WriteLine("Do you want to finish game?");
                        string finish = Console.ReadLine();
                        if (finish.Equals("Yes"))
                        {
                            game.Finish();
                        }
                    }
                }
            }
        }
示例#21
0
 public void InvokeCommand()
 {
     movable.Move(velocity);
 }
示例#22
0
 public virtual void Move(Vector2 movement)
 {
     _movable.Move(new Vector3(movement.x, 0, movement.y));
 }
示例#23
0
 private void FixedUpdate()
 {
     movableComponent.Move();
 }