コード例 #1
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);
            }
        }
コード例 #2
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;
        }