Example #1
0
 public TroopSpawnData(TroopTypeVO troop, IntPosition position, TroopSpawnMode mode, int amount)
 {
     this.TroopType     = troop;
     this.BoardPosition = position;
     this.SpawnMode     = mode;
     this.Amount        = amount;
 }
Example #2
0
        public SmartEntity SpawnChampion(TroopTypeVO troopType, TeamType teamType, IntPosition boardPosition)
        {
            TroopSpawnMode spawnMode   = (teamType == TeamType.Defender) ? TroopSpawnMode.LeashedToBuilding : TroopSpawnMode.Unleashed;
            SmartEntity    smartEntity = this.SpawnTroop(troopType, teamType, boardPosition, spawnMode, true, teamType == TeamType.Defender);

            if (smartEntity != null)
            {
                smartEntity.Add(new ChampionComponent(troopType));
            }
            return(smartEntity);
        }
Example #3
0
        public bool FinalizeSafeBoardPosition(TroopTypeVO troopType, ref Entity spawnBuilding, ref IntPosition boardPosition, ref BoardCell <Entity> targetCell, TeamType teamType, TroopSpawnMode spawnMode, bool forceAllow)
        {
            targetCell    = this.boardController.Board.GetClampedDeployableCellAt(boardPosition.x, boardPosition.z, troopType.SizeX);
            boardPosition = new IntPosition(targetCell.X, targetCell.Z);
            BoardCell <Entity> boardCell = null;

            if (spawnMode == TroopSpawnMode.LeashedToBuilding)
            {
                if (targetCell.Children == null)
                {
                    return(false);
                }
                LinkedListNode <BoardItem <Entity> > linkedListNode = targetCell.Children.First;
                while (linkedListNode != null)
                {
                    spawnBuilding = linkedListNode.Value.Data;
                    BuildingComponent   buildingComponent   = spawnBuilding.Get <BuildingComponent>();
                    DamageableComponent damageableComponent = spawnBuilding.Get <DamageableComponent>();
                    if (buildingComponent != null && (forceAllow || buildingComponent.BuildingType.AllowDefensiveSpawn) && damageableComponent != null)
                    {
                        if (forceAllow && troopType.Type == TroopType.Champion)
                        {
                            boardPosition = new IntPosition(targetCell.X, targetCell.Z);
                            break;
                        }
                        targetCell = damageableComponent.FindASafeSpawnSpot(troopType.SizeX, out boardCell);
                        if (targetCell == null)
                        {
                            return(false);
                        }
                        boardPosition = new IntPosition(targetCell.X, targetCell.Z);
                        break;
                    }
                    else
                    {
                        linkedListNode = linkedListNode.Next;
                    }
                }
                if (linkedListNode == null)
                {
                    return(false);
                }
            }
            else if (!this.ValidateTroopPlacement(boardPosition, teamType, troopType.SizeX, true, out boardCell, forceAllow))
            {
                return(false);
            }
            return(true);
        }
Example #4
0
        public SmartEntity SpawnTroop(TroopTypeVO troopType, TeamType teamType, IntPosition boardPosition, TroopSpawnMode spawnMode, bool sendPlacedEvent, bool forceAllow)
        {
            Entity             spawnBuilding = null;
            BoardCell <Entity> boardCell     = null;

            if (!this.FinalizeSafeBoardPosition(troopType, ref spawnBuilding, ref boardPosition, ref boardCell, teamType, spawnMode, forceAllow))
            {
                return(null);
            }
            SmartEntity smartEntity = Service.Get <EntityFactory>().CreateTroopEntity(troopType, teamType, boardPosition, spawnBuilding, spawnMode, true, true);

            if (smartEntity == null)
            {
                return(null);
            }
            BoardItemComponent boardItemComp = smartEntity.BoardItemComp;
            BoardItem <Entity> boardItem     = boardItemComp.BoardItem;

            if (Service.Get <BoardController>().Board.AddChild(boardItem, boardCell.X, boardCell.Z, null, false, !forceAllow && troopType.Type != TroopType.Champion) == null)
            {
                return(null);
            }
            Service.Get <EntityController>().AddEntity(smartEntity);
            Service.Get <TroopAbilityController>().OnTroopSpawned(smartEntity);
            if (troopType.Type != TroopType.Champion || teamType == TeamType.Attacker)
            {
                base.EnsureBattlePlayState();
            }
            if (sendPlacedEvent)
            {
                Service.Get <EventManager>().SendEvent(EventId.TroopPlacedOnBoard, smartEntity);
            }
            return(smartEntity);
        }
Example #5
0
 public SmartEntity SpawnTroop(TroopTypeVO troopType, TeamType teamType, IntPosition boardPosition, TroopSpawnMode spawnMode, bool sendPlacedEvent)
 {
     return(this.SpawnTroop(troopType, teamType, boardPosition, spawnMode, sendPlacedEvent, false));
 }
Example #6
0
        public SmartEntity CreateTroopEntity(TroopTypeVO troopType, TeamType teamType, IntPosition boardPosition, Entity spawnBuilding, TroopSpawnMode spawnMode, bool isShooter, bool requestAsset)
        {
            SmartEntity   smartEntity = this.CreateWalkerBaseEntity(boardPosition, troopType.SizeX, troopType.SizeY);
            TeamComponent component   = new TeamComponent(teamType);

            smartEntity.Add(component);
            if (teamType == TeamType.Defender)
            {
                DefenderComponent component2;
                if (spawnMode == TroopSpawnMode.LeashedToBuilding)
                {
                    DamageableComponent damageableComponent = spawnBuilding.Get <DamageableComponent>();
                    component2 = new DefenderComponent(boardPosition.x, boardPosition.z, damageableComponent, true, damageableComponent.GetLastSpawnIndex());
                }
                else
                {
                    component2 = new DefenderComponent(boardPosition.x, boardPosition.z, null, spawnMode == TroopSpawnMode.LeashedToSpawnPoint, 0);
                }
                smartEntity.Add(component2);
            }
            else
            {
                smartEntity.Add(new AttackerComponent());
            }
            TroopComponent troopComponent = new TroopComponent(troopType);

            smartEntity.Add(troopComponent);
            smartEntity.Add(new BuffComponent());
            smartEntity.Add(new HealthViewComponent());
            if (isShooter)
            {
                ShooterComponent component3 = new ShooterComponent(troopType);
                smartEntity.Add(component3);
            }
            Service.Get <EventManager>().SendEvent(EventId.TroopCreated, smartEntity);
            if (isShooter)
            {
                smartEntity.ShooterComp.TargetingDelayed = (teamType == TeamType.Attacker);
                HealthType healthType = troopType.IsHealer ? HealthType.Healing : HealthType.Damaging;
                smartEntity.ShooterComp.AttackFSM = new AttackFSM(Service.Get <BattleController>(), smartEntity, smartEntity.StateComp, smartEntity.ShooterComp, smartEntity.TransformComp, healthType);
                if (troopType.IsHealer)
                {
                    smartEntity.Add(new PathingComponent());
                    smartEntity.Add(new HealerComponent());
                }
                else
                {
                    smartEntity.Add(new KillerComponent());
                }
                SecondaryTargetsComponent component4 = new SecondaryTargetsComponent();
                smartEntity.Add(component4);
            }
            HealthComponent component5 = new HealthComponent(troopType.Health, troopComponent.TroopType.ArmorType);

            smartEntity.Add(component5);
            if (troopType.ShieldHealth > 0)
            {
                TroopShieldHealthComponent component6 = new TroopShieldHealthComponent(troopType.ShieldHealth, ArmorType.Shield);
                smartEntity.Add(component6);
            }
            if (requestAsset)
            {
                Service.Get <EntityViewManager>().LoadEntityAsset(smartEntity);
            }
            return(smartEntity);
        }
Example #7
0
 public SmartEntity SpawnTroop(TroopTypeVO troopType, TeamType teamType, IntPosition boardPosition, TroopSpawnMode spawnMode, bool sendPlacedEvent, bool forceAllow)
 {
     return(this.SpawnTroop(troopType, teamType, boardPosition, spawnMode, sendPlacedEvent, forceAllow, VisitorType.Invalid));
 }