Ejemplo n.º 1
0
 private void ThinkIntegrateChild()
 {
     if (this.m_LoadingChilds.Count == 0)
     {
         this.m_State = VonNeumannMomStates.COLLECT;
     }
     else
     {
         bool flag = true;
         foreach (GameObject loadingChild in this.m_LoadingChilds)
         {
             if (loadingChild.ObjectStatus != GameObjectStatus.Ready)
             {
                 flag = false;
             }
         }
         if (!flag)
         {
             return;
         }
         foreach (Ship loadingChild in this.m_LoadingChilds)
         {
             loadingChild.Player = this.m_VonNeumannMom.Player;
             loadingChild.Active = true;
             this.m_Game.CurrentState.AddGameObject((IGameObject)loadingChild, false);
         }
         this.m_State = VonNeumannMomStates.COLLECT;
     }
 }
Ejemplo n.º 2
0
        private void ThinkEmitChild()
        {
            VonNeumannChildSpawnLocations childSpawnLocations = this.m_SpawnLocations.FirstOrDefault <VonNeumannChildSpawnLocations>((Func <VonNeumannChildSpawnLocations, bool>)(x => x.CanSpawnAtLocation()));

            if (childSpawnLocations == null)
            {
                return;
            }
            Matrix rotationYpr = Matrix.CreateRotationYPR(this.m_VonNeumannMom.Maneuvering.Rotation);

            rotationYpr.Position = childSpawnLocations.GetSpawnLocation();
            Ship newShip = CombatAIController.CreateNewShip(this.m_Game.Game, rotationYpr, VonNeumann.StaticShipDesigns[VonNeumann.VonNeumannShipDesigns.CollectorProbe].DesignId, 0, this.m_VonNeumannMom.InputID, this.m_VonNeumannMom.Player.ObjectID);

            newShip.Maneuvering.RetreatDestination = this.m_VonNeumannMom.Maneuvering.RetreatDestination;
            if (newShip == null)
            {
                this.m_State = VonNeumannMomStates.COLLECT;
            }
            else
            {
                childSpawnLocations.SpawnAtLocation(newShip);
                this.m_RUStore -= this.m_Game.AssetDatabase.GlobalVonNeumannData.ChildRUCost;
                this.m_State    = VonNeumannMomStates.INTEGRATECHILD;
                this.m_LoadingChilds.Add(newShip);
            }
        }
Ejemplo n.º 3
0
        private void ThinkCollect()
        {
            if (this.m_RUStore >= this.m_Game.AssetDatabase.GlobalVonNeumannData.MomRUCost)
            {
                switch (this.m_Orders)
                {
                case VonNeumannOrders.COLLECT:
                    this.m_State = VonNeumannMomStates.INITFLEE;
                    break;

                default:
                    this.m_State = VonNeumannMomStates.EMITMOM;
                    break;
                }
            }
            else if (this.m_RUStore >= this.m_Game.AssetDatabase.GlobalVonNeumannData.ChildRUCost)
            {
                if (this.m_SpawnedChilds.Count >= this.m_NumChildrenToMaintain)
                {
                    return;
                }
                this.m_State = VonNeumannMomStates.EMITCHILD;
            }
            else
            {
                if (this.m_SpawnedChilds.Count >= this.m_Game.AssetDatabase.GlobalVonNeumannData.MinChildrenToMaintain || this.m_LoadingChilds.Count != 0)
                {
                    return;
                }
                this.m_RUStore += this.m_Game.AssetDatabase.GlobalVonNeumannData.ChildRUCost;
                this.m_State    = VonNeumannMomStates.EMITCHILD;
            }
        }
Ejemplo n.º 4
0
 public override void ForceFlee()
 {
     if (this.m_State == VonNeumannMomStates.INITFLEE || this.m_State == VonNeumannMomStates.FLEE)
     {
         return;
     }
     this.m_State = VonNeumannMomStates.INITFLEE;
 }
Ejemplo n.º 5
0
 private void ThinkFlee()
 {
     if (this.m_VonNeumannMom.CombatStance != CombatStance.RETREAT)
     {
         this.m_VonNeumannMom.SetCombatStance(CombatStance.RETREAT);
     }
     if (!this.m_VonNeumannMom.HasRetreated)
     {
         return;
     }
     this.m_State = VonNeumannMomStates.VANISH;
 }
Ejemplo n.º 6
0
 private void ThinkInitFlee()
 {
     this.m_State = VonNeumannMomStates.FLEE;
     foreach (CombatAIController spawnedChild in this.m_SpawnedChilds)
     {
         spawnedChild.ForceFlee();
     }
     foreach (CombatAIController spawnedMom in this.m_SpawnedMoms)
     {
         spawnedMom.ForceFlee();
     }
 }
Ejemplo n.º 7
0
        public override void OnThink()
        {
            if (this.m_VonNeumannMom == null)
            {
                return;
            }
            foreach (VonNeumannChildSpawnLocations spawnLocation in this.m_SpawnLocations)
            {
                spawnLocation.Update();
            }
            if (this.m_VonNeumannMom.IsDestroyed)
            {
                this.m_State = VonNeumannMomStates.INITFLEE;
            }
            else
            {
                this.ValidateChildren();
            }
            switch (this.m_State)
            {
            case VonNeumannMomStates.COLLECT:
                this.ThinkCollect();
                break;

            case VonNeumannMomStates.EMITCHILD:
                this.ThinkEmitChild();
                break;

            case VonNeumannMomStates.INTEGRATECHILD:
                this.ThinkIntegrateChild();
                break;

            case VonNeumannMomStates.EMITMOM:
                this.ThinkEmitMom();
                break;

            case VonNeumannMomStates.INTEGRATEMOM:
                this.ThinkIntegrateMom();
                break;

            case VonNeumannMomStates.INITFLEE:
                this.ThinkInitFlee();
                break;

            case VonNeumannMomStates.FLEE:
                this.ThinkFlee();
                break;

            case VonNeumannMomStates.VANISH:
                this.ThinkVanish();
                break;
            }
        }
Ejemplo n.º 8
0
 private void ThinkIntegrateMom()
 {
     if (this.m_LoadingMom == null)
     {
         this.m_State = VonNeumannMomStates.COLLECT;
     }
     else
     {
         if (this.m_LoadingMom.ObjectStatus != GameObjectStatus.Ready)
         {
             return;
         }
         this.m_LoadingMom.Active = true;
         this.m_LoadingMom.Player = this.m_VonNeumannMom.Player;
         this.m_Game.CurrentState.AddGameObject((IGameObject)this.m_LoadingMom, false);
         this.m_State = VonNeumannMomStates.INITFLEE;
     }
 }
Ejemplo n.º 9
0
        private void ThinkEmitMom()
        {
            this.m_RUStore -= this.m_Game.AssetDatabase.GlobalVonNeumannData.MomRUCost;
            Matrix rotationYpr = Matrix.CreateRotationYPR(this.m_VonNeumannMom.Maneuvering.Rotation);

            rotationYpr.Position = this.m_VonNeumannMom.Maneuvering.Position + rotationYpr.Forward * 500f;
            Ship newShip = CombatAIController.CreateNewShip(this.m_Game.Game, rotationYpr, VonNeumann.StaticShipDesigns[VonNeumann.VonNeumannShipDesigns.CollectorMothership].DesignId, 0, this.m_VonNeumannMom.InputID, this.m_VonNeumannMom.Player.ObjectID);

            if (newShip == null)
            {
                this.m_State = VonNeumannMomStates.COLLECT;
            }
            else
            {
                this.m_RUStore   -= this.m_Game.AssetDatabase.GlobalVonNeumannData.ChildRUCost;
                this.m_State      = VonNeumannMomStates.INTEGRATEMOM;
                this.m_LoadingMom = newShip;
            }
        }
Ejemplo n.º 10
0
        public override void Initialize()
        {
            this.m_LoadingMom              = (Ship)null;
            this.m_LoadingChilds           = new List <Ship>();
            this.m_SpawnedChilds           = new List <VonNeumannChildControl>();
            this.m_SpawnedMoms             = new List <VonNeumannMomControl>();
            this.m_SpawnLocations          = new List <VonNeumannChildSpawnLocations>();
            this.m_SpawnedDefensePlatforms = new List <Ship>();
            this.m_SpawnedEnemies          = new List <Ship>();
            this.m_State  = VonNeumannMomStates.COLLECT;
            this.m_Orders = VonNeumannOrders.COLLECT;
            this.m_NumChildrenToMaintain = 10;
            this.m_Vanished      = false;
            this.m_TryFindParent = true;
            this.m_VonNeumannID  = 0;
            VonNeumannInfo vonNeumannInfo = this.m_Game.GameDatabase.GetVonNeumannInfos().ToList <VonNeumannInfo>().FirstOrDefault <VonNeumannInfo>((Func <VonNeumannInfo, bool>)(x =>
            {
                int?fleetId1 = x.FleetId;
                int fleetId2 = this.m_FleetID;
                if (fleetId1.GetValueOrDefault() == fleetId2)
                {
                    return(fleetId1.HasValue);
                }
                return(false);
            }));

            if (vonNeumannInfo != null)
            {
                this.m_VonNeumannID = vonNeumannInfo.Id;
            }
            Matrix rotationYpr = Matrix.CreateRotationYPR(this.m_VonNeumannMom.Maneuvering.Rotation);

            rotationYpr.Position = this.m_VonNeumannMom.Maneuvering.Position + rotationYpr.Forward * 500f;
            Vector3 right               = rotationYpr.Right;
            int     designId            = VonNeumann.StaticShipDesigns[VonNeumann.VonNeumannShipDesigns.CollectorProbe].DesignId;
            int     childrenToMaintain1 = this.m_NumChildrenToMaintain;
            float   radians             = MathHelper.DegreesToRadians(360f / (float)childrenToMaintain1);
            float   num1 = radians * 0.5f;
            float   num2 = 1f;

            for (int index = 0; index < childrenToMaintain1; ++index)
            {
                float num3 = radians * (float)((index % childrenToMaintain1 + 1) / 2) * num2 + num1;
                this.m_SpawnLocations.Add(new VonNeumannChildSpawnLocations(this.m_VonNeumannMom, new Vector3((float)Math.Sin((double)num3), 0.0f, -(float)Math.Cos((double)num3)), 300f));
                num2 *= -1f;
            }
            int childrenToMaintain2 = this.m_Game.AssetDatabase.GlobalVonNeumannData.MinChildrenToMaintain;

            for (int index = 0; index < childrenToMaintain2; ++index)
            {
                VonNeumannChildSpawnLocations childSpawnLocations = this.m_SpawnLocations.FirstOrDefault <VonNeumannChildSpawnLocations>((Func <VonNeumannChildSpawnLocations, bool>)(x => x.CanSpawnAtLocation()));
                if (childSpawnLocations != null)
                {
                    Matrix worldMat = rotationYpr;
                    worldMat.Position = childSpawnLocations.GetSpawnLocation();
                    Ship newShip = CombatAIController.CreateNewShip(this.m_Game.Game, worldMat, designId, 0, this.m_VonNeumannMom.InputID, this.m_VonNeumannMom.Player.ObjectID);
                    if (newShip != null)
                    {
                        this.m_LoadingChilds.Add(newShip);
                        childSpawnLocations.SpawnAtLocation(newShip);
                    }
                }
            }
            if (this.m_LoadingChilds.Count <= 0)
            {
                return;
            }
            this.m_State = VonNeumannMomStates.INTEGRATECHILD;
        }