Esempio n. 1
0
 public bool IsCrushableBy(UnitMovementType umt, Player player)
 {
     if (player == self.Owner) return false;
     switch (umt)
     {
         case UnitMovementType.Track: return true;
         default: return false;
     }
 }
Esempio n. 2
0
 public float GetCost(UnitMovementType umt)
 {
     switch (umt)			/* todo: make this nice */
     {
         case UnitMovementType.Fly: return 1;
         case UnitMovementType.Foot: return 1 / Foot;
         case UnitMovementType.Wheel: return 1 / Wheel;
         case UnitMovementType.Track: return 1 / Track;
         case UnitMovementType.Float: return 1 / Float;
         default:
             throw new InvalidOperationException("wtf?");
     }
 }
Esempio n. 3
0
        public void SetUnitMoveType(UnitMovementType newMoveType)
        {
            currentUnitMoveType = newMoveType;

            switch (currentUnitMoveType)
            {
            case UnitMovementType.CharacterController:
                if (controller)
                {
                    deactivateOldMoveTypeController();
                    controller.gameObject.SetActive(true);
                }
                else
                {
                    currentUnitMoveType = oldUnitMoveType;
                }
                break;

            case UnitMovementType.NavMeshAgent:
                if (navAgent)
                {
                    deactivateOldMoveTypeController();
                    navAgent.gameObject.SetActive(true);
                }
                else
                {
                    currentUnitMoveType = oldUnitMoveType;
                }
                break;

            case UnitMovementType.Rigidbody:
                if (rb)
                {
                    deactivateOldMoveTypeController();
                    rb.gameObject.SetActive(true);
                }
                else
                {
                    currentUnitMoveType = oldUnitMoveType;
                }
                break;
            }
        }
Esempio n. 4
0
        public static PathSearch FromPoints(World world, IEnumerable<int2> froms, int2 target, UnitMovementType umt, bool checkForBlocked)
        {
            var search = new PathSearch(world)
            {
                heuristic = DefaultEstimator(target),
                umt = umt,
                checkForBlocked = checkForBlocked
            };

            foreach (var sl in froms)
                search.AddInitialCell(world, sl);

            return search;
        }
Esempio n. 5
0
        public static PathSearch FromPoint( World world, int2 from, int2 target, UnitMovementType umt, bool checkForBlocked )
        {
            var search = new PathSearch(world) {
                heuristic = DefaultEstimator( target ),
                umt = umt,
                checkForBlocked = checkForBlocked };

            search.AddInitialCell( world, from );
            return search;
        }
Esempio n. 6
0
        public static bool IsPathableCell(this World world, int2 a, UnitMovementType umt)
        {
            if (world.WorldActor.traits.Get<BuildingInfluence>().GetBuildingAt(a) != null) return false;
            if (world.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(a).Any()) return false;

            return world.Map.IsInMap(a.X, a.Y) &&
                Rules.TerrainTypes[world.TileSet.GetTerrainType(world.Map.MapTiles[a.X, a.Y])]
                .GetCost(umt) < float.PositiveInfinity;
        }
Esempio n. 7
0
 public static bool IsActorPathableToCrush(this World world, Actor a, UnitMovementType umt)
 {
     return a != null &&
             a.traits.WithInterface<ICrushable>()
             .Any(c => c.IsPathableCrush(umt, a.Owner));
 }
Esempio n. 8
0
 public bool IsPathableCrush(UnitMovementType umt, Player player)
 {
     return IsCrushableBy(umt, player);
 }
Esempio n. 9
0
 public float GetCost(int2 p, UnitMovementType umt)
 {
     return Rules.TerrainTypes[Templates[state].TerrainType[Tiles[p]]].GetCost(umt);
 }