private static List <MovementCost> GetPotentialMovementCosts(int terrainId, EnumerableList <string> movements) { var gameConfigCache = CallContext <GameConfigCache> .GetData("GameConfigCache"); var terrain = gameConfigCache.GetTerrainConfigById(terrainId); var potentialMovementCosts = new List <MovementCost>(); foreach (var unitMovement in movements) { foreach (var terrainMovement in terrain.Movements) { var movement = gameConfigCache.GetMovementConfigById((int)terrainMovement.MovementId); if (unitMovement != movement.Name) { continue; } if ((float)terrainMovement.Cost > 0.0f) { var movementCost = new MovementCost(movement.Name, (float)terrainMovement.Cost); potentialMovementCosts.Add(movementCost); } } } return(potentialMovementCosts); }
// Use this for initialization void Start() { gameManager = GameObject.Find("GameManager"); movementCost = gameManager.GetComponent <MovementCost> (); pirateExit.GetComponent <Button> ().onClick.AddListener(HidePirateMenu); repairBtn.GetComponent <Button> ().onClick.AddListener(Repair); }
public GameMapMovementRoute(int startX, int startY) { StartX = startX; StartY = startY; EndX = startX; EndY = startY; // The start of a route has no direction _route.Add(Direction.None); RouteCost = new MovementCost(); }
public static MovementCost Max(MovementCost c1, MovementCost c2) { if (c1.UnableReason != OrderInvalidReason.NONE) { return(c1); } if (c2.UnableReason != OrderInvalidReason.NONE) { return(c2); } return(c1.Cost > c2.Cost ? c1 : c2); }
void Start() { cannonsCreated = 0; cannons = new GameObject[cannonNumber]; selectedCannon = null; gameManager = GameObject.Find("GameManager"); cost = gameManager.GetComponent <MovementCost> (); cannonExit.GetComponent <Button> ().onClick.AddListener(HideCannonMenu); turnLeft.GetComponent <Button> ().onClick.AddListener(CannonTurnLeft); turnRight.GetComponent <Button> ().onClick.AddListener(CannonTurnRight); fire.GetComponent <Button> ().onClick.AddListener(CannonFire); }
public Enterability IsEnterable() { // This returns true if you can enter this tile right this moment. if (MovementCost.IsZero()) { return(Enterability.Never); } // Check out furniture to see if it has a special block on enterability if (Furniture != null) { return(Furniture.IsEnterable()); } return(Enterability.Yes); }
private int[,] MakeFinishedPath() { int[,] Buffer = new int[Grid.GetLength(0), Grid.GetLength(1)]; int[,] Result = new int[Grid.GetLength(0), Grid.GetLength(1)]; // A legnagyobb movement costot keressük előbb. int[] Start = new int[3]; for (int x = 0; x < MovementCost.GetLength(0); x++) { for (int y = 0; y < MovementCost.GetLength(1); y++) { if (MovementCost[x, y] != 0 && MovementCost[x, y] > Start[2]) { Start[0] = x; Start[1] = y; Start[2] = MovementCost[x, y]; } } } // Legnagyobb érték felrakása a kezdő értékhez. Amit visszaadunk, az egy tömb indexelve a visszamenetet! Buffer[Start[0], Start[1]] = Start[2]; Result[Start[0], Start[1]] = 1; int SearchValue = 0; int[] Next = new int[3]; Next = Start; int Cycle = 1; while (Next[0] != StartPoint[0] || Next[1] != StartPoint[1]) { SearchValue = Next[2] - GValue[0]; Next = ParentsFinishedPath(Next[0], Next[1], SearchValue); if (Next[0] != StartPoint[0] || Next[1] != StartPoint[1]) { Buffer[Next[0], Next[1]] = SearchValue; Result[Next[0], Next[1]] = Cycle + 1; } Cycle++; } return(Result); }
public GameMapMovementRoute(IGameMapMovementRoute toCopy, Direction addedDirection, MovementCost addedCost) { StartX = toCopy.StartX; StartY = toCopy.StartY; _route.AddRange(toCopy.Route); _route.Add(addedDirection); RouteCost = toCopy.RouteCost + addedCost; EndX = toCopy.EndX; EndY = toCopy.EndY; switch (addedDirection) { case Direction.East: EndX++; break; case Direction.West: EndX--; break; case Direction.North: EndY++; break; case Direction.South: EndY--; break; } }
public IGameMapMovementRoute CreateExtendRoute(Direction newDirection, MovementCost newDirectionCost) { return(new GameMapMovementRoute(this, newDirection, newDirectionCost)); }
void Start() { gameManager = GameObject.Find("GameManager"); movementCost = gameManager.GetComponent <MovementCost> (); }