override public void SetAgentDestination(Vector3 destination) { if (spawnComponent == null) { spawnComponent = GetComponent <SpawnComponent>(); if (spawnComponent == null) { SpawnComponentTutorial = GetComponent <SpawnComponentTutorial>(); if (SpawnComponentTutorial == null) { Debug.LogError("StaticSpawnerMoveComponent error: No spawnComponent found"); return; } } } if (spawnComponent != null) { spawnComponent.waypointLocation.position = destination; } else { SpawnComponentTutorial.waypointLocation.position = destination; } }
public SpawnQueueItem(Image image, Text text, MyObject myObject, SpawnComponent spawnComponent, Text costText) { UICooldownImage = image; queueLength = text; thingToSpawn = myObject; this.spawnComponent = spawnComponent; this.costText = costText; nrOfQueue = 0; gameManager = GameObject.FindObjectOfType <GameManager>(); UICooldownImage.GetComponentInParent <SpawnUIButtonScript>().SpawnQueueItem = this; }
public FishSpawnerSystem(SpawnComponent spawnComp) { cam = Camera.main; Vector2 ScreenPos = new Vector2(Screen.width, Screen.height); Vector3 CameraBound = cam.ScreenToWorldPoint(ScreenPos); CameraBound.y = 0; MinX = -CameraBound.x; MinZ = -CameraBound.z; MaxX = CameraBound.x; MaxZ = CameraBound.z; }
private IEntity _createSpawn(Vector2 position) { var entity = _pool.CreateEntity(); var spawnComponent = new SpawnComponent() { position = position }; entity.AddComponent(spawnComponent); entity.AddComponent(new ViewComponent()); return(entity); }
public ComponentManager(Game1 mygame) { myGame = mygame; systemsManager = myGame.SystemManager; components = new List <IComponent>(); // Initiate ComponentInstance components.Add(cSelectionHandler = new SelectionHandlerComponent(systemsManager.sSelectionHandler)); components.Add(cMovement = new MovementComponent(systemsManager.sMovement)); components.Add(cHealth = new HealthComponent(systemsManager.sHealth)); components.Add(cSpawn = new SpawnComponent(systemsManager.sSpawn)); components.Add(cCollision = new CollisionComponent(systemsManager.sCollision)); }
protected virtual void Awake() { EventList.waveChanged += Insect_OnWaveChange; moveComponent = GetComponent <MovementComponent>(); spawn = GetComponent <SpawnComponent>(); baseSprite = transform.GetChild(0).GetComponent <SpriteRenderer>(); currentColor = baseSprite.color; polyCollider = GetComponent <PolygonCollider2D>(); if (polyCollider == null) { polyCollider = GetComponentInChildren <PolygonCollider2D>(true); } moveComponent.MoveSpeed = baseSpeed; }
public void Tick(ref SpawnComponent spawnComp) { DolphinTimer -= Time.deltaTime; HammerSharkTimer -= Time.deltaTime; JellyFishTimer -= Time.deltaTime; KoiFishTimer -= Time.deltaTime; OrthoconeTimer -= Time.deltaTime; TurtleTimer -= Time.deltaTime; KillerWhaleTimer -= Time.deltaTime; if (DolphinTimer <= 0) { Spawn(FishType.Dolphin); DolphinTimer = spawnComp.SpawnTime / spawnComp.DolphinPerSec; } if (HammerSharkTimer <= 0) { Spawn(FishType.HammerShark); HammerSharkTimer = spawnComp.SpawnTime / spawnComp.HammerSharkPerSec; } if (JellyFishTimer <= 0) { Spawn(FishType.JellyFish); JellyFishTimer = spawnComp.SpawnTime / spawnComp.JellyFishPerSec; } if (KoiFishTimer <= 0) { Spawn(FishType.KoiFish); KoiFishTimer = spawnComp.SpawnTime / spawnComp.KoiFishPerSec; } if (OrthoconeTimer <= 0) { Spawn(FishType.Orthocone); OrthoconeTimer = spawnComp.SpawnTime / spawnComp.OrthoconePerSec; } if (TurtleTimer <= 0) { Spawn(FishType.Turtle); TurtleTimer = spawnComp.SpawnTime / spawnComp.TurtlePerSec; } if (KillerWhaleTimer <= 0) { Spawn(FishType.KillerWhale); KillerWhaleTimer = spawnComp.SpawnTime / spawnComp.KillerWhalePerSec; } }
public EatResponse OnEvent(EventId id, object cookie) { if (id == EventId.TroopPlacedOnBoard) { if (this.IsEventValidForGoal()) { SmartEntity smartEntity = (SmartEntity)cookie; TroopComponent troopComponent = smartEntity.Get <TroopComponent>(); TeamComponent teamComponent = smartEntity.Get <TeamComponent>(); SpawnComponent spawnComponent = smartEntity.Get <SpawnComponent>(); if (teamComponent != null && teamComponent.TeamType == TeamType.Attacker && troopComponent != null && troopComponent.TroopType.TroopID == this.troopId && (spawnComponent == null || !spawnComponent.IsSummoned())) { this.parent.Progress(this, 1); } } } return(EatResponse.NotEaten); }
public SmartEntity SpawnTroop(TroopTypeVO troopType, TeamType teamType, IntPosition boardPosition, TroopSpawnMode spawnMode, bool sendPlacedEvent, bool forceAllow, VisitorType visitorType) { Entity spawnBuilding = null; BoardCell boardCell = null; if (!this.FinalizeSafeBoardPosition(troopType, ref spawnBuilding, ref boardPosition, ref boardCell, teamType, spawnMode, forceAllow)) { return(null); } SmartEntity smartEntity = Service.EntityFactory.CreateTroopEntity(troopType, teamType, boardPosition, spawnBuilding, spawnMode, true, true); if (smartEntity == null) { return(null); } SpawnComponent component = new SpawnComponent(visitorType); smartEntity.Add(component); BoardItemComponent boardItemComp = smartEntity.BoardItemComp; BoardItem boardItem = boardItemComp.BoardItem; if (Service.BoardController.Board.AddChild(boardItem, boardCell.X, boardCell.Z, null, false, !forceAllow && troopType.Type != TroopType.Champion) == null) { return(null); } Service.EntityController.AddEntity(smartEntity); Service.TroopAbilityController.OnTroopSpawned(smartEntity); if (troopType.Type != TroopType.Champion || teamType == TeamType.Attacker) { base.EnsureBattlePlayState(); } if (sendPlacedEvent) { Service.EventManager.SendEvent(EventId.TroopPlacedOnBoard, smartEntity); } return(smartEntity); }
public override object Remove(Type compCls) { if (compCls == typeof(AreaTriggerComponent)) { this.AreaTriggerComp = null; } else if (compCls == typeof(ArmoryComponent)) { this.ArmoryComp = null; } else if (compCls == typeof(AssetComponent)) { this.AssetComp = null; } else if (compCls == typeof(AttackerComponent)) { this.AttackerComp = null; } else if (compCls == typeof(BarracksComponent)) { this.BarracksComp = null; } else if (compCls == typeof(BoardItemComponent)) { this.BoardItemComp = null; } else if (compCls == typeof(BuildingAnimationComponent)) { this.BuildingAnimationComp = null; } else if (compCls == typeof(BuildingComponent)) { this.BuildingComp = null; } else if (compCls == typeof(CantinaComponent)) { this.CantinaComp = null; } else if (compCls == typeof(ChampionComponent)) { this.ChampionComp = null; } else if (compCls == typeof(CivilianComponent)) { this.CivilianComp = null; } else if (compCls == typeof(ClearableComponent)) { this.ClearableComp = null; } else if (compCls == typeof(DamageableComponent)) { this.DamageableComp = null; } else if (compCls == typeof(DefenderComponent)) { this.DefenderComp = null; } else if (compCls == typeof(DefenseLabComponent)) { this.DefenseLabComp = null; } else if (compCls == typeof(DroidComponent)) { this.DroidComp = null; } else if (compCls == typeof(DroidHutComponent)) { this.DroidHutComp = null; } else if (compCls == typeof(SquadBuildingComponent)) { this.SquadBuildingComp = null; } else if (compCls == typeof(NavigationCenterComponent)) { this.NavigationCenterComp = null; } else if (compCls == typeof(FactoryComponent)) { this.FactoryComp = null; } else if (compCls == typeof(FleetCommandComponent)) { this.FleetCommandComp = null; } else if (compCls == typeof(FollowerComponent)) { this.FollowerComp = null; } else if (compCls == typeof(GameObjectViewComponent)) { this.GameObjectViewComp = null; } else if (compCls == typeof(GeneratorComponent)) { this.GeneratorComp = null; } else if (compCls == typeof(GeneratorViewComponent)) { this.GeneratorViewComp = null; } else if (compCls == typeof(HealerComponent)) { this.HealerComp = null; } else if (compCls == typeof(HealthComponent)) { this.HealthComp = null; } else if (compCls == typeof(TroopShieldComponent)) { this.TroopShieldComp = null; } else if (compCls == typeof(TroopShieldViewComponent)) { this.TroopShieldViewComp = null; } else if (compCls == typeof(TroopShieldHealthComponent)) { this.TroopShieldHealthComp = null; } else if (compCls == typeof(HealthViewComponent)) { this.HealthViewComp = null; } else if (compCls == typeof(HQComponent)) { this.HQComp = null; } else if (compCls == typeof(KillerComponent)) { this.KillerComp = null; } else if (compCls == typeof(LootComponent)) { this.LootComp = null; } else if (compCls == typeof(MeterShaderComponent)) { this.MeterShaderComp = null; } else if (compCls == typeof(OffenseLabComponent)) { this.OffenseLabComp = null; } else if (compCls == typeof(PathingComponent)) { this.PathingComp = null; } else if (compCls == typeof(SecondaryTargetsComponent)) { this.SecondaryTargetsComp = null; } else if (compCls == typeof(ShieldBorderComponent)) { this.ShieldBorderComp = null; } else if (compCls == typeof(ShieldGeneratorComponent)) { this.ShieldGeneratorComp = null; } else if (compCls == typeof(SizeComponent)) { this.SizeComp = null; } else if (compCls == typeof(ShooterComponent)) { this.ShooterComp = null; } else if (compCls == typeof(StarportComponent)) { this.StarportComp = null; } else if (compCls == typeof(StateComponent)) { this.StateComp = null; } else if (compCls == typeof(StorageComponent)) { this.StorageComp = null; } else if (compCls == typeof(SupportComponent)) { this.SupportComp = null; } else if (compCls == typeof(SupportViewComponent)) { this.SupportViewComp = null; } else if (compCls == typeof(TacticalCommandComponent)) { this.TacticalCommandComp = null; } else if (compCls == typeof(ChampionPlatformComponent)) { this.ChampionPlatformComp = null; } else if (compCls == typeof(TeamComponent)) { this.TeamComp = null; } else if (compCls == typeof(TrackingComponent)) { this.TrackingComp = null; } else if (compCls == typeof(TrackingGameObjectViewComponent)) { this.TrackingGameObjectViewComp = null; } else if (compCls == typeof(TransformComponent)) { this.TransformComp = null; } else if (compCls == typeof(TransportComponent)) { this.TransportComp = null; } else if (compCls == typeof(TroopComponent)) { this.TroopComp = null; } else if (compCls == typeof(TurretBuildingComponent)) { this.TurretBuildingComp = null; } else if (compCls == typeof(TurretShooterComponent)) { this.TurretShooterComp = null; } else if (compCls == typeof(WalkerComponent)) { this.WalkerComp = null; } else if (compCls == typeof(WallComponent)) { this.WallComp = null; } else if (compCls == typeof(BuffComponent)) { this.BuffComp = null; } else if (compCls == typeof(TrapComponent)) { this.TrapComp = null; } else if (compCls == typeof(TrapViewComponent)) { this.TrapViewComp = null; } else if (compCls == typeof(HousingComponent)) { this.HousingComp = null; } else if (compCls == typeof(SpawnComponent)) { this.SpawnComp = null; } return(base.Remove(compCls)); }
protected override Entity AddComponentAndDispatchAddEvent(ComponentBase comp, Type compCls) { bool flag = false; if (comp is AreaTriggerComponent) { this.AreaTriggerComp = (AreaTriggerComponent)comp; flag = true; } if (comp is ArmoryComponent) { this.ArmoryComp = (ArmoryComponent)comp; flag = true; } if (comp is AssetComponent) { this.AssetComp = (AssetComponent)comp; flag = true; } if (comp is AttackerComponent) { this.AttackerComp = (AttackerComponent)comp; flag = true; } if (comp is BarracksComponent) { this.BarracksComp = (BarracksComponent)comp; flag = true; } if (comp is BoardItemComponent) { this.BoardItemComp = (BoardItemComponent)comp; flag = true; } if (comp is BuildingAnimationComponent) { this.BuildingAnimationComp = (BuildingAnimationComponent)comp; flag = true; } if (comp is BuildingComponent) { this.BuildingComp = (BuildingComponent)comp; flag = true; } if (comp is ChampionComponent) { this.ChampionComp = (ChampionComponent)comp; flag = true; } if (comp is CivilianComponent) { this.CivilianComp = (CivilianComponent)comp; flag = true; } if (comp is ClearableComponent) { this.ClearableComp = (ClearableComponent)comp; flag = true; } if (comp is DamageableComponent) { this.DamageableComp = (DamageableComponent)comp; flag = true; } if (comp is DefenderComponent) { this.DefenderComp = (DefenderComponent)comp; flag = true; } if (comp is DefenseLabComponent) { this.DefenseLabComp = (DefenseLabComponent)comp; flag = true; } if (comp is DroidComponent) { this.DroidComp = (DroidComponent)comp; flag = true; } if (comp is DroidHutComponent) { this.DroidHutComp = (DroidHutComponent)comp; flag = true; } if (comp is SquadBuildingComponent) { this.SquadBuildingComp = (SquadBuildingComponent)comp; flag = true; } if (comp is NavigationCenterComponent) { this.NavigationCenterComp = (NavigationCenterComponent)comp; flag = true; } if (comp is FactoryComponent) { this.FactoryComp = (FactoryComponent)comp; flag = true; } if (comp is CantinaComponent) { this.CantinaComp = (CantinaComponent)comp; flag = true; } if (comp is FleetCommandComponent) { this.FleetCommandComp = (FleetCommandComponent)comp; flag = true; } if (comp is FollowerComponent) { this.FollowerComp = (FollowerComponent)comp; flag = true; } if (comp is GameObjectViewComponent) { this.GameObjectViewComp = (GameObjectViewComponent)comp; flag = true; } if (comp is GeneratorComponent) { this.GeneratorComp = (GeneratorComponent)comp; flag = true; } if (comp is GeneratorViewComponent) { this.GeneratorViewComp = (GeneratorViewComponent)comp; flag = true; } if (comp is HealerComponent) { this.HealerComp = (HealerComponent)comp; flag = true; } if (comp is TroopShieldComponent) { this.TroopShieldComp = (TroopShieldComponent)comp; flag = true; } if (comp is TroopShieldViewComponent) { this.TroopShieldViewComp = (TroopShieldViewComponent)comp; flag = true; } if (comp is TroopShieldHealthComponent) { this.TroopShieldHealthComp = (TroopShieldHealthComponent)comp; flag = true; } if (comp is HealthComponent) { this.HealthComp = (HealthComponent)comp; flag = true; } if (comp is HealthViewComponent) { this.HealthViewComp = (HealthViewComponent)comp; flag = true; } if (comp is HQComponent) { this.HQComp = (HQComponent)comp; flag = true; } if (comp is KillerComponent) { this.KillerComp = (KillerComponent)comp; flag = true; } if (comp is LootComponent) { this.LootComp = (LootComponent)comp; flag = true; } if (comp is MeterShaderComponent) { this.MeterShaderComp = (MeterShaderComponent)comp; flag = true; } if (comp is OffenseLabComponent) { this.OffenseLabComp = (OffenseLabComponent)comp; flag = true; } if (comp is PathingComponent) { this.PathingComp = (PathingComponent)comp; flag = true; } if (comp is SecondaryTargetsComponent) { this.SecondaryTargetsComp = (SecondaryTargetsComponent)comp; flag = true; } if (comp is ShieldBorderComponent) { this.ShieldBorderComp = (ShieldBorderComponent)comp; flag = true; } if (comp is ShieldGeneratorComponent) { this.ShieldGeneratorComp = (ShieldGeneratorComponent)comp; flag = true; } if (comp is SizeComponent) { this.SizeComp = (SizeComponent)comp; flag = true; } if (comp is ShooterComponent) { this.ShooterComp = (ShooterComponent)comp; flag = true; } if (comp is StarportComponent) { this.StarportComp = (StarportComponent)comp; flag = true; } if (comp is StateComponent) { this.StateComp = (StateComponent)comp; flag = true; } if (comp is StorageComponent) { this.StorageComp = (StorageComponent)comp; flag = true; } if (comp is SupportComponent) { this.SupportComp = (SupportComponent)comp; flag = true; } if (comp is SupportViewComponent) { this.SupportViewComp = (SupportViewComponent)comp; flag = true; } if (comp is TacticalCommandComponent) { this.TacticalCommandComp = (TacticalCommandComponent)comp; flag = true; } if (comp is ChampionPlatformComponent) { this.ChampionPlatformComp = (ChampionPlatformComponent)comp; flag = true; } if (comp is TeamComponent) { this.TeamComp = (TeamComponent)comp; flag = true; } if (comp is TrackingComponent) { this.TrackingComp = (TrackingComponent)comp; flag = true; } if (comp is TrackingGameObjectViewComponent) { this.TrackingGameObjectViewComp = (TrackingGameObjectViewComponent)comp; flag = true; } if (comp is TransformComponent) { this.TransformComp = (TransformComponent)comp; flag = true; } if (comp is TransportComponent) { this.TransportComp = (TransportComponent)comp; flag = true; } if (comp is TroopComponent) { this.TroopComp = (TroopComponent)comp; flag = true; } if (comp is TurretBuildingComponent) { this.TurretBuildingComp = (TurretBuildingComponent)comp; flag = true; } if (comp is TurretShooterComponent) { this.TurretShooterComp = (TurretShooterComponent)comp; flag = true; } if (comp is WalkerComponent) { this.WalkerComp = (WalkerComponent)comp; flag = true; } if (comp is WallComponent) { this.WallComp = (WallComponent)comp; flag = true; } if (comp is BuffComponent) { this.BuffComp = (BuffComponent)comp; flag = true; } if (comp is TrapComponent) { this.TrapComp = (TrapComponent)comp; flag = true; } if (comp is TrapViewComponent) { this.TrapViewComp = (TrapViewComponent)comp; flag = true; } if (comp is HousingComponent) { this.HousingComp = (HousingComponent)comp; flag = true; } if (comp is ScoutTowerComponent) { this.ScoutTowerComp = (ScoutTowerComponent)comp; flag = true; } if (comp is SpawnComponent) { this.SpawnComp = (SpawnComponent)comp; flag = true; } if (!flag && compCls != null) { Service.Logger.Error("Invalid component add: " + compCls.Name); } return(base.AddComponentAndDispatchAddEvent(comp, compCls)); }
public override void Initialize(SpawnComponent spawnComponent) { base.Initialize(spawnComponent); base.OnAllAgentsFromPeerSpawnedFromVisuals += this.OnAllAgentsFromPeerSpawnedFromVisuals; }
private void OnEnable() { spawnComponent = GetComponent <SpawnComponent>(); spawnComponent.OnUnitSpawned += AddNewUnit; }
void IEcsRunSystem.Run() { spawns.Clear(); players.Clear(); foreach (var i in spawnsFilter) { spawns.Add(spawnsFilter.Get1(i)); } foreach (var i in playersFilter) { players.Add(playersFilter.Get1(i)); } //Debug.Log(events.GetEntitiesCount()); // Это необходимо для правильной очередности // появления игроков, если мы подключаемся к уже созданной игре List <Player> photonPlayers = new List <Player>(); foreach (var e in events) { photonPlayers.Add(events.Get1(e).player); } //photonPlayers.ForEach(p => Debug.Log(p.photonView.OwnerActorNr + " -***")); photonPlayers = photonPlayers.OrderBy(p => p.photonView.OwnerActorNr).ToList(); //photonPlayers.ForEach(p => Debug.Log(p.photonView.OwnerActorNr + " -+++")); foreach (var e in photonPlayers) { //Debug.Log($"{PhotonNetwork.PlayerList.Length % 2} ..."); var spawned = e; var player = players.Find(p => p.view == spawned); EcsEntity entity = GetPlayerEntity(player); entity.Get <HealthPointComponent>().Value = player.maxHealthPoint; foreach (var b in battleFilter) { ref var battle = ref battleFilter.Get1(b); bool isSpawned = false; SpawnComponent spawn = default; // Получение порядкового номера var id = int.Parse(e.photonView.ViewID.ToString().Substring(2)); //Debug.Log(id + " ==-=--=--=-="); if (id % 2 > 0) { if (GetRandomSpawn(SpawnType.Command_1, out spawn)) { battle.teamOne.Add(entity); entity.Get <PlayerComponent>().teamNum = TeamNum.One; player.teamNum = TeamNum.One; isSpawned = true; } //entity.Get<HealthPointComponent>().Value = 50; } else { if (GetRandomSpawn(SpawnType.Command_2, out spawn)) { battle.teamTwo.Add(entity); entity.Get <PlayerComponent>().teamNum = TeamNum.Two; player.teamNum = TeamNum.Two; isSpawned = true; } } if (isSpawned) { player.view.collider.enabled = true; player.view.OnDamage(player.maxHealthPoint); if (player.view.photonView.IsMine) { player.view.transform.position = spawn.pos + GetRandomOffset(); } //Debug.Log($"тима двэ {battle.teamTwo.Count} || тима одын {battle.teamOne.Count} поз хуёз {player.view.transform.position}"); } } }
public SpawnSystem(SpawnComponent _spawnComp) { spawnComp = _spawnComp; }
protected override void Awake() { base.Awake(); eggSpawn = GetComponent <SpawnComponent>(); }