Esempio n. 1
0
        /// <summary>
        /// Checks if tank is near Paris. Then moves it to Moscow. Otherwise, moves it back to Paris.
        /// </summary>
        void MoveTankAndFollow()
        {
            string destinationCity, destinationCountry;

            if (tank == null)
            {
                DropTankOnCity();
            }

            // Gets position of Paris in map
            Vector2 parisPosition = map.GetCity("Paris", "France").unity2DLocation;

            // Is the tank nearby (less than 50 km)? Then set destination to Moscow, otherwize Paris again
            if (map.calc.Distance(tank.currentMap2DLocation, parisPosition) < 50000)
            {
                destinationCity    = "Moscow";
                destinationCountry = "Russia";
            }
            else
            {
                destinationCity    = "Paris";
                destinationCountry = "France";
            }

            // Get position of destination
            Vector2 destination = map.GetCity(destinationCity, destinationCountry).unity2DLocation;

            // For this movement, we will move the tank following a straight line
            tank.terrainCapability = TERRAIN_CAPABILITY.Any;

            // Move the tank to the new position with smooth ease
            tank.easeType = EASE_TYPE.SmoothStep;

            // Use a close zoom during follow - either current zoom level or 0.1f maximum so tank is watched closely
            tank.follow          = true;
            tank.followZoomLevel = Mathf.Min(0.1f, map.GetZoomLevel());

            // Move it!
            tank.MoveTo(destination, 4.0f);

            // Finally, signal me when tank stops
            tank.OnMoveEnd += (thisTank) => Debug.Log("Tank has stopped at " + thisTank.currentMap2DLocation + " location.");
        }
Esempio n. 2
0
        /// <summary>
        /// Moves the tank with path finding.
        /// </summary>
        void MoveTankWithPathFinding(Vector2 destination)
        {
            // Ensure tank is limited terrain, avoid water
            if (tank == null)
            {
                DropTankOnCity();
                return;
            }

            // If current path is visible then fade it.
            if (pathLine != null)
            {
                pathLine.FadeOut(1.0f);
            }

            tank.terrainCapability = TERRAIN_CAPABILITY.OnlyGround;
            tank.MoveTo(destination, 0.1f);
        }
Esempio n. 3
0
        /// <summary>
        /// Moves the tank with path finding.
        /// </summary>
        void MoveTankWithPathFinding(Vector2 destination)
        {
            // Setup custom route matrix - first we reset it
            map.PathFindingCustomRouteMatrixReset();

            //  Then set a cost of 0 (unbreakable) on those location belonging to a different player to prevent the tank move over those non-controlled zones.
            int tankPlayer = tank.attrib["player"];

            europeanCountries.ForEach((country) => {
                int countryPlayer = country.attrib["player"];
                if (countryPlayer != tankPlayer)
                {
                    map.PathFindingCustomRouteMatrixSet(country, 0);
                }
            });

            tank.MoveTo(destination, 0.1f);
        }
    void MoveUnitWithPathFinding(Vector2 destination)
    {
        army = map.VGOLastClicked;
        bool canMove = false;

        Debug.Log("Are we going to move now?");
        animator.SetBool(key_isWalking, true);
        // animator.Play(walk);

        // army.GetComponent<Animator>().SetBool(key_isRun, true);
        canMove = army.MoveTo(destination, 0.33f);
        Debug.Log(canMove);
        selected = false;
        if (!canMove)
        {
            Debug.Log("Can't move to destination!");
        }
        // animator.Play(walk);
    }