public NavyTask_Takeover(AILayer_Navy navyLayer, Fortress fortress) : base(navyLayer) { base.TargetGuid = fortress.GUID; this.FortressPosition = fortress.WorldPosition; base.Behavior = new NavyBehavior_Interception(); base.Behavior.Initialize(); }
void Start() { player = GameObject.Find("Player").GetComponent <Player> (); fortress = GameObject.Find("Fortress").GetComponent <Fortress> (); StartConnection(); StartCoroutine("SendPlayerPosition"); }
public void InitOffender(IEnemyTemplate et, Waypoint[] waypoints, GameConfig gameConfig, EnemyController enemyController, GameController gameController, Fortress fortress) { cus = new CombatUnitStats(et.CombatUnitStats.HitPoints, et.CombatUnitStats.HitPointsIncrement, et.CombatUnitStats.Damage, et.CombatUnitStats.DamageIncrement, et.CombatUnitStats.AttackCooldown); es = new EnemyStats(et.EnemyStats.Bounty, et.EnemyStats.BountyIncrement, et.EnemyStats.MoveSpeed, et.EnemyStats.MoveSpeedIncrement); SetStatsLevel(0); this.gameConfig = gameConfig; this.waypoints = waypoints; this.enemyController = enemyController; this.gameController = gameController; this.fortress = fortress; waypointProxy = gameConfig.WaypointProximity; currentWaypoint = 0; waypointVectors = new Vector3[waypoints.Length]; for (int i = 0; i < waypoints.Length; i++) { waypointVectors[i] = waypoints[i].Position; } t = transform; sr = GetComponent <SpriteRenderer>(); Status = OffenderStatus.Pooled; //look at first waypoint ResetOffender(); }
public void Bind(Fortress fortress, global::Empire empire, GameObject client, bool oceanicRegionList) { if (this.Fortress != null) { this.Unbind(); } if (this.GarrisonShortcutButton != null) { if (oceanicRegionList) { this.GarrisonShortcutButton.OnActivateObject = base.gameObject; this.GarrisonShortcutButton.OnActivateMethod = "OnGarrisonShortcutCB"; this.GarrisonShortcutButton.OnDoubleClickObject = base.gameObject; this.GarrisonShortcutButton.OnDoubleClickMethod = "OnFortressShortcutCB"; } else { this.GarrisonShortcutButton.OnActivateObject = base.gameObject; this.GarrisonShortcutButton.OnActivateMethod = "OnFortressShortcutCB"; this.GarrisonShortcutButton.OnDoubleClickObject = null; this.GarrisonShortcutButton.OnDoubleClickMethod = null; } } this.fromOceanicRegionList = oceanicRegionList; this.selectionClient = client; this.Empire = empire; this.Fortress = fortress; this.Fortress.Refreshed += this.Fortress_Refreshed; IGameService service = Services.GetService <IGameService>(); this.PlayerController = service.Game.Services.GetService <IPlayerControllerRepositoryService>().ActivePlayerController; this.WorldPositionningService = service.Game.Services.GetService <IWorldPositionningService>(); this.updateFacilityDelegate = new AgeTransform.RefreshTableItem <PointOfInterest>(this.UpdateFacility); }
public void MergeFrom(ClientMapPoi other) { if (other == null) { return; } if (other.Id.Length != 0) { Id = other.Id; } if (other.Name.Length != 0) { Name = other.Name; } if (other.Latitude != 0D) { Latitude = other.Latitude; } if (other.Longitude != 0D) { Longitude = other.Longitude; } if (other.Description.Length != 0) { Description = other.Description; } if (other.PoiAccessibility != 0) { PoiAccessibility = other.PoiAccessibility; } switch (other.TypeCase) { case TypeOneofCase.Outpost: if (Outpost == null) { Outpost = new global::WUProtos.Data.Client.ClientMapOutpost(); } Outpost.MergeFrom(other.Outpost); break; case TypeOneofCase.Fortress: if (Fortress == null) { Fortress = new global::WUProtos.Data.Client.ClientMapFortress(); } Fortress.MergeFrom(other.Fortress); break; case TypeOneofCase.Greenhouse: if (Greenhouse == null) { Greenhouse = new global::WUProtos.Data.Client.ClientMapGreenhouse(); } Greenhouse.MergeFrom(other.Greenhouse); break; } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
private void HandleInstanceProperties() { Fortress fortress = GetComponent <Fortress>(); fortress.ID = Mathf.FloorToInt(transform.position.x + transform.position.y * 200); DestroyImmediate(GetComponent <TiledLoaderProperties>()); DestroyImmediate(this, true); }
private void RefreshFortressLine(AgeTransform tableitem, Fortress fortress, int index) { tableitem.StartNewMesh = true; FortressLine component = tableitem.GetComponent <FortressLine>(); component.Bind(fortress, this.Empire, this.selectionClient.gameObject, false); component.RefreshContent(); component.AgeTransform.Enable = true; component.DisableIfGarrisonIsInEncounter(); }
public void OnStart() { _popupManager.ShowPopup(nameof(LevelPopup)); _fortressController = new FortressController(); _fortress = _fortressController.SpawnFortress(); _enemies.Add(_enemyController.SpawnEnemy()); EventManager.Subscribe <OnEnemyIsDeadEvent>(OnEnemyIsDead); EventManager.Subscribe <OnGameOverEvent>(OnGameOver); }
public NavyFortress(AILayer_Navy navyLayer, Fortress fortress) { this.Fortress = fortress; base.Garrison = fortress; this.navyLayer = navyLayer; IGameService service = Services.GetService <IGameService>(); this.worldPositionService = service.Game.Services.GetService <IWorldPositionningService>(); this.WantToKeepArmyFitness = new HeuristicValue(0f); this.lastcheckTime = 0.0; }
private void OnFortressInit(Event a_Event, params object[] a_Params) { Fortress fortress = a_Params[0] as Fortress; if (fortress == null || fortress != m_FortressParent) { return; } OnInit(fortress); }
private void OnFortressDied(Event a_Event, params object[] a_Params) { Fortress fortress = a_Params[0] as Fortress; // The 'this == null' call is surprisingly necessary when in the editor... if (fortress == null || fortress != m_FortressParent || this == null) { return; } Destroy(gameObject); }
public Projectile(Vector2f position, Vector2f velocity, Texture texture, Color palette, int xScale, int yScale, int width, int height, Fortress fortress) { this.sprite = new Sprite(texture) { Position = position, Color = palette, Scale = new Vector2f(xScale, yScale) }; this.fortress = fortress; Velocity = velocity; Width = width; Height = height; }
protected bool IsCloseEnoughToAttack(Army army, IGarrison target) { City city = target as City; District district = target as District; if (district != null) { city = district.City; } if (city != null && army.IsNaval) { District district2 = this.worldPositionService.GetDistrict(army.WorldPosition); return(district2 != null && district2.City == city); } Fortress fortress = target as Fortress; if (fortress != null) { if (this.worldPositionService.GetDistance(army.WorldPosition, fortress.WorldPosition) == 1 && this.pathfindingService.IsTransitionPassable(army.WorldPosition, fortress.WorldPosition, army, OrderAttack.AttackFlags, null)) { return(true); } for (int i = 0; i < fortress.Facilities.Count; i++) { if (this.worldPositionService.GetDistance(army.WorldPosition, fortress.Facilities[i].WorldPosition) == 1 && this.pathfindingService.IsTransitionPassable(army.WorldPosition, fortress.Facilities[i].WorldPosition, army, OrderAttack.AttackFlags, null)) { return(true); } } } IGameEntityWithWorldPosition gameEntityWithWorldPosition = target as IGameEntityWithWorldPosition; if (gameEntityWithWorldPosition != null) { if (this.worldPositionService.GetDistance(army.WorldPosition, gameEntityWithWorldPosition.WorldPosition) > 1) { return(false); } if (army.IsSeafaring && !this.worldPositionService.IsOceanTile(gameEntityWithWorldPosition.WorldPosition)) { return(false); } if (this.worldPositionService.IsWaterTile(army.WorldPosition) != this.worldPositionService.IsWaterTile(gameEntityWithWorldPosition.WorldPosition)) { return(false); } if (this.pathfindingService.IsTransitionPassable(army.WorldPosition, gameEntityWithWorldPosition.WorldPosition, army, OrderAttack.AttackFlags, null)) { return(true); } } return(false); }
private void Start() { panelChild = transform.GetChild(0); foreach (Fortress fortress in FindObjectsOfType <Fortress>()) { if (fortress.isFortressControlledByPlayer) { myFortress = fortress; } } panelChild.GetChild(0).GetComponent <Button>().onClick.AddListener(ForgeCreationButtonClicked); panelChild.GetChild(1).GetComponent <Button>().onClick.AddListener(BarracksCreationButtonClicked); }
private void OnFortressLocationShortcut() { Fortress currentFortress = FortressLine.CurrentFortress; this.OnCloseCB(null); IViewService service = Services.GetService <IViewService>(); if (service != null) { service.SelectAndCenter(currentFortress, false); } this.Hide(false); }
// Use this for initialization void Start() { //要塞取得。 _Fortress = GetComponent <Fortress>(); //補給確認リスト制作。 for (int i = 0; i < bulletNum; i++) { _Supplied.Add(false); } //補給開始。 StartCoroutine(Supplying()); }
//ダメージテキストを表示。 //[in] 表示するダメージ。 //[in] 表示する場所の基点。 //[in] タグ。 public void DisplayDamageText(int damage, Vector3 pos, Fortress fortress) { //非アクティブなテキストを取得。 Text text = _TextList.Find((a) => a.gameObject.activeSelf == false); text.gameObject.SetActive(true); //少しずらす。 int range = 100; text.transform.position = pos + new Vector3(Random.Range(-range, range), Random.Range(-range, range)); //ダメージ設定。 text.text = damage.ToString(); // text.gameObject.GetComponent <DamageText>().fortress = fortress; }
protected WorldPosition GetBestFacilitiesToAttack(ArmyWithTask army, Fortress fortress) { int num = this.worldPositionService.GetDistance(army.Garrison.WorldPosition, fortress.WorldPosition); WorldPosition worldPosition = fortress.WorldPosition; for (int i = 0; i < fortress.Facilities.Count; i++) { int distance = this.worldPositionService.GetDistance(army.Garrison.WorldPosition, fortress.Facilities[i].WorldPosition); if (distance < num) { num = distance; worldPosition = fortress.Facilities[i].WorldPosition; } } return(worldPosition); }
public override int GetHashCode() { int hash = 1; if (Id.Length != 0) { hash ^= Id.GetHashCode(); } if (Name.Length != 0) { hash ^= Name.GetHashCode(); } if (Latitude != 0D) { hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(Latitude); } if (Longitude != 0D) { hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(Longitude); } if (Description.Length != 0) { hash ^= Description.GetHashCode(); } if (typeCase_ == TypeOneofCase.Outpost) { hash ^= Outpost.GetHashCode(); } if (typeCase_ == TypeOneofCase.Fortress) { hash ^= Fortress.GetHashCode(); } if (typeCase_ == TypeOneofCase.Greenhouse) { hash ^= Greenhouse.GetHashCode(); } if (PoiAccessibility != 0) { hash ^= PoiAccessibility.GetHashCode(); } hash ^= (int)typeCase_; if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public void Bind(Fortress fortress) { GuiElement guiElement = null; this.Fortress = fortress; for (int i = 0; i < this.typesFIDS.Count; i++) { base.GuiService.GuiPanelHelper.TryGetGuiElement(this.typesFIDS[i], out guiElement, this.Fortress.Occupant.Faction.Name); if (guiElement != null) { ExtendedGuiElement extendedGuiElement = (ExtendedGuiElement)guiElement; if (i < this.TotalValuesTable.GetChildren().Count) { AgeTransform ageTransform = this.TotalValuesTable.GetChildren()[i]; for (int j = 0; j < ageTransform.GetChildren().Count; j++) { AgeTooltip component = ageTransform.GetComponent <AgeTooltip>(); if (component != null) { component.Class = "Simple"; component.Content = extendedGuiElement.Description; } AgeTransform ageTransform2 = ageTransform.GetChildren()[j]; if (ageTransform2.name == "1Symbol") { Texture2D image; if (base.GuiService.GuiPanelHelper.TryGetTextureFromIcon(guiElement, global::GuiPanel.IconSize.Small, out image)) { ageTransform2.GetComponent <AgePrimitiveImage>().Image = image; ageTransform2.GetComponent <AgePrimitiveImage>().TintColor = extendedGuiElement.Color; } break; } } } } SimulationPropertyTooltipData simulationPropertyTooltipData = this.valuesFIDS[i].AgeTransform.AgeTooltip.ClientData as SimulationPropertyTooltipData; if (simulationPropertyTooltipData != null) { simulationPropertyTooltipData.Context = this.Fortress; } } IGameService service = Services.GetService <IGameService>(); this.PlayerController = service.Game.Services.GetService <IPlayerControllerRepositoryService>().ActivePlayerController; this.updateFacilityDelegate = new AgeTransform.RefreshTableItem <PointOfInterest>(this.UpdateFacility); }
public void Init(Fortress fortress, GameController gameController) { InitUIElements(); killsPrefix = "Kills: "; wavePrefix = "Wave: "; goldPrefix = "Gold: "; gameOverWavePrefix = "Waves survived: "; gameOverKillsPrefix = "Total kills "; fortress.fortressTakeDamage.AddListener(OnFortressTakeDamage); fortress.fortressDestroyed.AddListener(OnFortressDestroyed); this.fortress = fortress; this.gameController = gameController; ResetUI(); Debug.Log(gameController); }
public void GenerateFillFortress(Fortress fortress) { NavyTask_FillFortress navyTask_FillFortress = this.navyLayer.FindTask <NavyTask_FillFortress>((NavyTask_FillFortress match) => match.TargetGuid == fortress.GUID); if (navyTask_FillFortress != null) { return; } NavyFortress navyFortress = this.NavyFortresses.Find((NavyFortress match) => match.Fortress.GUID == fortress.GUID); if (navyFortress == null) { return; } navyTask_FillFortress = new NavyTask_FillFortress(this.navyLayer, navyFortress); this.navyLayer.NavyTasks.Add(navyTask_FillFortress); }
public Amplitude.Unity.Game.Orders.Order CreateArmyFromFortress(BaseNavyArmy army) { if (!this.IsFortress(army)) { return(null); } WorldPosition armyPosition = WorldPosition.Invalid; WorldOrientation orientation = WorldOrientation.East; if (army.MainAttackableTarget != null) { orientation = this.worldPositionService.GetOrientation(army.Garrison.WorldPosition, army.MainAttackableTarget.WorldPosition); } Fortress fortress = army.Garrison as Fortress; for (int i = 0; i < 6; i++) { WorldPosition neighbourTile = this.worldPositionService.GetNeighbourTile(fortress.WorldPosition, orientation.Rotate(i), 1); if (DepartmentOfDefense.CheckWhetherTargetPositionIsValidForUseAsArmySpawnLocation(neighbourTile, PathfindingMovementCapacity.Water)) { armyPosition = neighbourTile; break; } } if (!armyPosition.IsValid) { for (int j = 0; j < fortress.Facilities.Count; j++) { for (int k = 0; k < 6; k++) { WorldPosition neighbourTile2 = this.worldPositionService.GetNeighbourTile(fortress.Facilities[j].WorldPosition, (WorldOrientation)k, 1); if (DepartmentOfDefense.CheckWhetherTargetPositionIsValidForUseAsArmySpawnLocation(neighbourTile2, PathfindingMovementCapacity.Water)) { armyPosition = neighbourTile2; break; } } } } GameEntityGUID[] array = new GameEntityGUID[army.Garrison.StandardUnits.Count]; for (int l = 0; l < army.Garrison.StandardUnits.Count; l++) { array[l] = army.Garrison.StandardUnits[l].GUID; } return(new OrderTransferGarrisonToNewArmy(army.Garrison.Empire.Index, army.Garrison.GUID, array, armyPosition, null, false, true, true)); }
protected WorldPosition GetValidTileToAttack(ArmyWithTask navalArmy, IGameEntityWithWorldPosition entityWithPosition) { WorldPosition worldPosition = entityWithPosition.WorldPosition; Fortress fortress = entityWithPosition as Fortress; if (fortress != null) { worldPosition = this.GetBestFacilitiesToAttack(navalArmy, fortress); } City city = entityWithPosition as City; if (city != null) { return(this.GetBestDistrictToAttack(navalArmy, city)); } Army army = navalArmy.Garrison as Army; if (army == null) { return(WorldPosition.Invalid); } bool flag = this.worldPositionService.IsWaterTile(worldPosition); bool isSeafaring = army.IsSeafaring; WorldOrientation worldOrientation = this.worldPositionService.GetOrientation(worldPosition, army.WorldPosition); for (int i = 0; i < 6; i++) { WorldPosition neighbourTile = this.worldPositionService.GetNeighbourTile(worldPosition, worldOrientation, 1); bool flag2 = this.worldPositionService.IsWaterTile(neighbourTile); if ((isSeafaring || !army.IsNaval || flag == flag2) && neighbourTile.IsValid && ((!isSeafaring && flag == flag2) || this.worldPositionService.IsOceanTile(neighbourTile)) && this.pathfindingService.IsTransitionPassable(neighbourTile, worldPosition, army, OrderAttack.AttackFlags, null) && this.pathfindingService.IsTileStopableAndPassable(neighbourTile, army, PathfindingFlags.IgnoreFogOfWar, null)) { return(neighbourTile); } if (i % 2 == 0) { worldOrientation = worldOrientation.Rotate(-(i + 1)); } else { worldOrientation = worldOrientation.Rotate(i + 1); } } return(WorldPosition.Invalid); }
private void GenerateTakeOver(Fortress fortress) { if (fortress.Occupant != null && !this.navyLayer.MightAttackOwner(fortress.Region, fortress.Occupant)) { return; } if (fortress.Occupant != null && base.Owner is MajorEmpire && this.navyLayer.diplomacyLayer.GetPeaceWish(fortress.Occupant.Index)) { return; } NavyTask_Takeover navyTask_Takeover = this.navyLayer.FindTask <NavyTask_Takeover>((NavyTask_Takeover match) => match.TargetGuid == fortress.GUID); if (navyTask_Takeover != null) { return; } navyTask_Takeover = new NavyTask_Takeover(this.navyLayer, fortress); this.navyLayer.NavyTasks.Add(navyTask_Takeover); }
public override bool CheckValidity() { Region region = Services.GetService <IGameService>().Game.Services.GetService <IWorldPositionningService>().GetRegion(this.FortressPosition); if (region.NavalEmpire == null) { return(false); } PirateCouncil agency = region.NavalEmpire.GetAgency <PirateCouncil>(); if (agency == null) { return(false); } Fortress fortressAt = agency.GetFortressAt(this.FortressPosition); if (fortressAt == null) { return(false); } if (fortressAt.Occupant != null && !base.NavyLayer.MightAttackOwner(region, fortressAt.Occupant)) { return(false); } if (base.Owner is MajorEmpire && fortressAt.Occupant != null && base.NavyLayer.diplomacyLayer.GetPeaceWish(fortressAt.Occupant.Index)) { return(false); } if (base.AssignedArmy != null && base.AssignedArmy.Garrison == null) { base.AssignedArmy = null; base.CurrentAssignationFitness.Reset(); } if (base.AssignedArmy != null) { float enemyPower = this.GetEnemyPower(); if (base.AssignedArmy.Garrison.GetPropertyValue(SimulationProperties.MilitaryPower) < enemyPower * 0.8f) { return(false); } } return(true); }
private static void HandlePlayerSync(PlayerSync sync) { if (sync == null) { throw new WrongPacketTypeException(); } // Remove inactive players Fortress fortress = World.Instance.GetFortress(sync.FortressID); fortress.SetVisible(true); fortress.Initialize(sync.UserID, sync.Team); fortress.SetToScore(sync.Score); if (!sync.Active) { World.Instance.RemovePlayer(sync.UserID); return; } Player player = World.Instance.GetOrAddPlayer(sync.UserID, sync.FortressID); player.UpdateFromServer(sync); }
private float GetEnemyPower() { Region region = Services.GetService <IGameService>().Game.Services.GetService <IWorldPositionningService>().GetRegion(this.FortressPosition); if (region.NavalEmpire == null) { return(0f); } PirateCouncil agency = region.NavalEmpire.GetAgency <PirateCouncil>(); if (agency == null) { return(0f); } Fortress fortressAt = agency.GetFortressAt(this.FortressPosition); if (fortressAt == null) { return(0f); } return(fortressAt.GetPropertyValue(SimulationProperties.MilitaryPower)); }
private void Awake() { if (Instance == null) { Instance = this; } if (_victoryWindow == null || _closeVictoryWindow == null || _hpSlider == null || _gold == null || _face == null || _texts.Length == 0) { Debug.LogError("Object reference is null!"); } else { _hpSlider.maxValue = Hp; _hpSlider.value = Hp; _closeVictoryWindow.onClick.AddListener(CloseVictoryWindow); _gold.SetActive(false); _victoryWindow.SetActive(false); } }
private List <IWorldPositionable> Execute_GetFortresses(AIBehaviorTree aiBehaviorTree, Army army, IGameService gameService, List <IWorldPositionable> unfilteredTargetList) { List <IWorldPositionable> list = new List <IWorldPositionable>(); for (int i = 0; i < unfilteredTargetList.Count; i++) { PointOfInterest pointOfInterest = unfilteredTargetList[i] as PointOfInterest; Fortress fortressAt = null; if (pointOfInterest != null && (pointOfInterest.Type == Fortress.Citadel || pointOfInterest.Type == Fortress.Facility)) { fortressAt = pointOfInterest.Region.NavalEmpire.GetAgency <PirateCouncil>().GetFortressAt(pointOfInterest.WorldPosition); } else { fortressAt = (unfilteredTargetList[i] as Fortress); } if (fortressAt != null && !list.Exists((IWorldPositionable f) => f.WorldPosition == fortressAt.WorldPosition)) { list.Add(fortressAt); } } return(list); }