public GateDefenceSystem(CastleForm form, WorldDirection direct) { moat = new Moat(form); gate = new Gate(direct, BuildMaterial.wood, false); isBridgeDown = false; isTarTrapSet = false; }
internal static Vector3 GetWorldDirection(WorldDirection direction) { switch (direction) { default: return(Vector3.zero); // World case WorldDirection.Up: return(Vector3.up); case WorldDirection.Down: return(Vector3.down); case WorldDirection.Forward: return(Vector3.forward); case WorldDirection.Backward: return(Vector3.back); case WorldDirection.Left: return(Vector3.left); case WorldDirection.Right: return(Vector3.right); } }
public void Push(WorldDirection worldDirection) { var collisionResults = Helper.GetCollisions(Unit, worldDirection); // Push unit if no other units will be hit. // Otherwise apply 1 damage to each unit. if (collisionResults.Count == 0) { Unit.MoveInDirection(worldDirection); } else { foreach (var pushbackResult in collisionResults) { Assert.IsNotNull(pushbackResult.Occupant); pushbackResult.Occupant.Health.Modify(-1); if (Helper.CanReachTile(pushbackResult.transform.GetGridPosition(), worldDirection)) { Unit.MoveInDirection(worldDirection); } } } }
public bool takeAttack(List <DirectedAttack> attackVectors) { WorldDirection gatePos = gateDefSys.getPosition(); List <DirectedAttack> gateDirectedAttacks = new List <DirectedAttack>(); int i = 0; while (i < attackVectors.Count) { if (attackVectors[i].direction == gatePos) { gateDirectedAttacks.Add(attackVectors[i]); attackVectors.RemoveAt(i); } else { i++; } } bool result = false; foreach (DirectedAttack gateAttack in gateDirectedAttacks) { result = result || gateDefSys.takeDamage(gateAttack); } if (result) { return(true); } result = result || wallDefSys.takeDamage(attackVectors); return(result); }
/// <summary> /// return the angle for turned sprite between "from" and "to" directions /// </summary> /// <param name="from">direction 'from' where it is coming</param> /// <param name="to">direction 'to' where it is going</param> private float GetTurnedSnakeAngle(WorldDirection from, WorldDirection to) { switch (from) { case WorldDirection.Up: return(GetTurnSide(to) ? Constants.AngleFromToDirection.UP_TO_RIGHT : Constants.AngleFromToDirection.UP_TO_LEFT); case WorldDirection.Down: return(GetTurnSide(to) ? Constants.AngleFromToDirection.DOWN_TO_RIGHT : Constants.AngleFromToDirection.DOWN_TO_LEFT); case WorldDirection.Left: return(GetTurnSide(to) ? Constants.AngleFromToDirection.DOWN_TO_RIGHT : Constants.AngleFromToDirection.UP_TO_RIGHT); case WorldDirection.Right: return(GetTurnSide(to) ? Constants.AngleFromToDirection.DOWN_TO_LEFT : Constants.AngleFromToDirection.UP_TO_LEFT); } return(0f); }
public List <TileResult> GetTiles(Tile origin, WorldDirection direction, int offset, int length, TileFilterMode filterMode = TileFilterMode.None) { Assert.IsNotNull(origin, "Origin tile is null."); length = Mathf.Min(GridSize, length); var hitTiles = new List <TileResult>(); // Start one tile away from origin. for (int i = offset + 1; i < offset + 1 + length; i++) { var vectorFromDirection = GridHelper.DirectionToVector(direction); var nextTile = GetTile(origin.transform.GetGridPosition() + vectorFromDirection * i); if (nextTile) { if (filterMode != TileFilterMode.None && nextTile.Blocked) { if (filterMode == TileFilterMode.ContiguousTilesInclusive) { hitTiles.Add(new TileResult(nextTile, i)); } break; } hitTiles.Add(new TileResult(nextTile, i)); } } return(hitTiles); }
public DefenceUnit(int _MAX_defense, WorldDirection worldDirect, BuildMaterial buildMaterial) { MAX_defense = _MAX_defense; defense = _MAX_defense; position = worldDirect; material = buildMaterial; guard_count = 0; warriors = null; dmgPerGuardian = default_dmg_per_guardian; }
public void RegisterPush(Tile tile, WorldDirection worldDirection) { if (_pushes.ContainsKey(tile)) { DebugEx.LogWarning <EffectPreview>("Trying to register a push on a tile that already has a push registered."); } else { _pushes.Add(tile, worldDirection); } }
private GameObject SpawnPushMarker(Tile tile, WorldDirection worldDirection) { Assert.IsNotNull(_pushMarkerPrototype); var instance = GameObject.Instantiate(_pushMarkerPrototype); instance.transform.SetGridPosition(tile.transform.GetGridPosition()); instance.transform.position += Vector3.up * 0.01f; instance.transform.rotation = GridHelper.DirectionToQuaternion(worldDirection); return(instance); }
private Castle(string _name, CastleForm extForm, WorldDirection extPos, CastleForm intForm, WorldDirection intPos, int res_count, int serv_count, int war_count) { name = _name; externalDefSys = new ExternalDefenceSystem(extForm, extPos); internalDefSys = new InternalDefenceSystem(intForm, intPos); waterDistribSys = new WaterDistributionSystem(); livingSys = new JustLivingSystem(res_count, serv_count, war_count); comfyLivingSys = new ComfyLivingSystem(); prisonSys = new PrisonSystem(); isUnderAttack = false; isUnderSiege = false; isUnderFeudal = false; currentFeudal = null; }
public static Castle getInstance(string _name, CastleForm extForm, WorldDirection extPos, CastleForm intForm, WorldDirection intPos, int res_count, int serv_count, int war_count) { if (instance == null) { lock (syncRoot) { if (instance == null) { instance = new Castle(_name, extForm, extPos, intForm, intPos, res_count, serv_count, war_count); } } } return(instance); }
public List <Tile> GetCollisions(Unit source, WorldDirection direction) { var results = new List <Tile>(); var nextTile = GetTileInDirection(source, direction); while (nextTile != null && nextTile.Occupant != null) { results.Add(nextTile); nextTile = GetTileInDirection(nextTile, direction); } return(results); }
public static Vector2 DirectionToVector(WorldDirection direction) { switch (direction) { case WorldDirection.North: return(Vector2.up); case WorldDirection.East: return(Vector2.right); case WorldDirection.South: return(Vector2.down); case WorldDirection.West: return(Vector2.left); } return(Vector2.zero); }
public static Quaternion DirectionToQuaternion(WorldDirection worldDirection) { switch (worldDirection) { case WorldDirection.North: return(Quaternion.AngleAxis(0f, Vector3.up)); case WorldDirection.East: return(Quaternion.AngleAxis(90f, Vector3.up)); case WorldDirection.South: return(Quaternion.AngleAxis(180f, Vector3.up)); case WorldDirection.West: return(Quaternion.AngleAxis(270f, Vector3.up)); } return(Quaternion.identity); }
//-------------------------------------------------------------------------- public void TransitionToChunk(WorldDirection chunkDir, string sceneName) { WorldChunkIndex newChunkIndex = _currentIndx + WorldDirectionUtils.GetWorldChunkOffset(chunkDir); // make sure we have the chunk cached (else, we should be warping) WorldChunk newChunk = _chunkCache[newChunkIndex]; DebugUtils.Assert(newChunk != null, "WorldManager::Transition() - '{0}' was not cached at ({1},{2}), try calling WarpToChunk() instead.", sceneName, newChunkIndex.x, newChunkIndex.y); // switch focus to the new chunk newChunk.AddLoadCompleteDelegate(delegate(string loadedSceneName) { DebugUtils.Assert(loadedSceneName == sceneName, "WorldManager::Transition() - '{0}' was not the chunk we found at ({1},{2}), '{3}' was", sceneName, newChunkIndex.x, newChunkIndex.y, loadedSceneName); SetFocusedChunk(sceneName, newChunkIndex); }); }
public InternalDefenceSystem(CastleForm form, WorldDirection direct) { wallDefSys = new WallDefenceSystem(form); gateDefSys = new GateDefenceSystem(form, direct); donjonTower = new DonjonTower(); }
/// <summary> /// returns true if the snake is going to up or right or false to left or down /// </summary> /// <param name="to">direction to where the snake is going</param> private bool GetTurnSide(WorldDirection to) { return(to == WorldDirection.Up || to == WorldDirection.Right); }
public ExternalDefenceSystem(CastleForm form, WorldDirection direct) { wallDefSys = new WallDefenceSystem(form); gateDefSys = new GateDefenceSystem(form, direct); isDefenceDown = false; }
public Tower(WorldDirection worldDirect, BuildMaterial buildMaterial, int attackdmg) : base(worldDirect, buildMaterial) { attackDmg = attackdmg; }
public Tower(int _MAX_defense, WorldDirection worldDirect, BuildMaterial buildMaterial, int attackdmg) : base(_MAX_defense, worldDirect, buildMaterial) { attackDmg = attackdmg; }
public Tile GetTileInDirection(Unit origin, WorldDirection direction) { return(GetTile(origin.transform.GetGridPosition() + GridHelper.DirectionToVector(direction))); }
public ProjectileCollisionEvent(Collider collider, WorldDirection direction) { Collider = collider; Direction = direction; }
public void ApplyForce(WorldDirection moveDirection, Action <ProjectileCollisionEvent> callback = null) { _moveDirection = moveDirection; _callback = callback; }
/// <summary> /// Called when an adjacent tile's metadata is changed. /// </summary> /// <param name="x">The x-coordinate of the current tile.</param> /// <param name="y">The y-coordinate of the current tile.</param> /// <param name="z">The z-level of the tiles.</param> /// <param name="nx">The x-coordinate of the tile that changed.</param> /// <param name="ny">The y-coordinate of the tile that changed.</param> /// <param name="dir">The direction from the current tile to the tile that changed.</param> /// <param name="oldMeta">The old metadata value of the tile that changed.</param> /// <param name="newMeta">The new metadata value of the tile that changed.</param> public virtual void OnAdjacentMetadataChange(int x, int y, int z, int nx, int ny, WorldDirection dir, byte oldMeta, byte newMeta) { }
/// <summary> /// Called when an adjacent tile is changed from one tile type to another. /// </summary> /// <param name="x">The x-coordinate of the current tile.</param> /// <param name="y">The y-coordinate of the current tile.</param> /// <param name="z">The z-level of the tiles.</param> /// <param name="nx">The x-coordinate of the tile that changed.</param> /// <param name="ny">The y-coordinate of the tile that changed.</param> /// <param name="dir">The direction from the current tile to the tile that changed.</param> /// <param name="oldTile">The changed tile's old tile type.</param> /// <param name="newTile">The changed tile's new tile type.</param> public virtual void OnAdjacentChange(int x, int y, int z, int nx, int ny, WorldDirection dir, Tile oldTile, Tile newTile) { }
/// <summary> /// Gets the tile adjacent to (x, y) in the provided direction. /// </summary> /// <param name="x">The x-coordinate to get adjacent to.</param> /// <param name="y">The y-coordinate to get adjacent to.</param> /// <param name="z">The z-level to get the tile to the left of.</param> /// <param name="dir">The direction to look for the adjacent tile in.</param> /// <returns>The adjecent tile found with the passed settings.</returns> public Tile GetAdjacentTile(int x, int y, int z, WorldDirection dir) { switch (dir) { case WorldDirection.Left: return Left(x, y, z); case WorldDirection.Right: return Right(x, y, z); case WorldDirection.Up: return Up(x, y, z); case WorldDirection.Down: return Down(x, y, z); } return null; // Never reached }
public Gate(WorldDirection worldDirect, BuildMaterial buildMaterial, bool isOpen) : base(worldDirect, buildMaterial) { isGateOpen = isOpen; }
public bool MoveInDirection(WorldDirection worldDirection) { return(MoveTo(_helper.GetTileInDirection(this, worldDirection))); }
public Gate(int _MAX_defense, WorldDirection worldDirect, BuildMaterial buildMaterial, bool isOpen) : base(_MAX_defense, worldDirect, buildMaterial) { isGateOpen = isOpen; }
public bool CanReachTile(Vector2 origin, WorldDirection direction, int distance = 0) { return(GetReachableTiles(origin, distance).Count > 0); }