コード例 #1
0
        private void OnEditBot(MyMwcObjectBuilder_SmallShip bldr, MySmallShipTemplate smallShipTemplate)
        {
            BotTemplate newTemplate = new BotTemplate();
            MyMwcObjectBuilder_SmallShip_Bot botBuilder = bldr as MyMwcObjectBuilder_SmallShip_Bot;

            newTemplate.m_builder = new MyMwcObjectBuilder_SmallShip_Bot(
                smallShipTemplate.Builder.ShipType,
                null,
                null,
                null,
                smallShipTemplate.Builder.AssignmentOfAmmo,
                null,
                null,
                smallShipTemplate.Builder.ShipMaxHealth,
                smallShipTemplate.Builder.ShipHealthRatio,
                smallShipTemplate.Builder.ArmorHealth,
                smallShipTemplate.Builder.Oxygen,
                smallShipTemplate.Builder.Fuel,
                smallShipTemplate.Builder.ReflectorLight,
                smallShipTemplate.Builder.ReflectorLongRange,
                smallShipTemplate.Builder.Faction,
                botBuilder != null ? botBuilder.AITemplate : MyAITemplateEnum.DEFAULT,
                botBuilder != null ? botBuilder.Aggressivity : 0,
                botBuilder != null ? botBuilder.SeeDistance : 1000,
                botBuilder != null ? botBuilder.SleepDistance : 1000,
                MyPatrolMode.CYCLE,
                null,
                BotBehaviorType.IDLE,
                MyLightsConstants.MAX_SPOTLIGHT_SHADOW_RANGE, bldr.AIPriority, false, true); // faction will be assigned after spawnpoint genertation
            newTemplate.m_builder.ShipTemplateID = smallShipTemplate.ID;
            newTemplate.m_name = smallShipTemplate.Name.ToString();
            int key = m_selectShipsListbox.GetSelectedItem().Key;
            m_selectShipsListbox.RemoveItem(key);
            
            m_selectShipsListbox.AddItem(key, smallShipTemplate.Name);

            m_bots[key] = newTemplate;
        }
コード例 #2
0
        private void AddBot(MyMwcObjectBuilder_SmallShip bldr, MySmallShipTemplate smallShipTemplate)
        {
            BotTemplate newTemplate = new BotTemplate();
            MyMwcObjectBuilder_SmallShip_Bot botBuilder = bldr as MyMwcObjectBuilder_SmallShip_Bot;            

            newTemplate.m_builder = new MyMwcObjectBuilder_SmallShip_Bot(
                smallShipTemplate.Builder.ShipType,
                null,
                null,
                null,
                smallShipTemplate.Builder.AssignmentOfAmmo,
                null,
                null,
                smallShipTemplate.Builder.ShipMaxHealth,
                smallShipTemplate.Builder.ShipHealthRatio,
                smallShipTemplate.Builder.ArmorHealth,
                smallShipTemplate.Builder.Oxygen,
                smallShipTemplate.Builder.Fuel,
                smallShipTemplate.Builder.ReflectorLight,
                smallShipTemplate.Builder.ReflectorLongRange,
                smallShipTemplate.Builder.Faction,
                botBuilder != null ? botBuilder.AITemplate : MyAITemplateEnum.DEFAULT,
                botBuilder != null ? botBuilder.Aggressivity : 0,
                botBuilder != null ? botBuilder.SeeDistance : 1000,
                botBuilder != null ? botBuilder.SleepDistance : 1000,
                MyPatrolMode.CYCLE,
                null,
                BotBehaviorType.IDLE,
                MyLightsConstants.MAX_SPOTLIGHT_SHADOW_RANGE, 0, false, true); // faction will be assigned after spawnpoint genertation
            newTemplate.m_builder.ShipTemplateID = smallShipTemplate.ID;            
            
            newTemplate.m_name = smallShipTemplate.Name.ToString();

            // find nearest new non template index
            int index = -1;
            foreach (int key in m_bots.Keys)
            {
                if (index < key && key < TEMPLATE_INDEX_OFFSET)
                {
                    index = key;
                }
            }
            index++;

            AddBot(index, newTemplate);

        }
コード例 #3
0
        private void OnEditBot(MyMwcObjectBuilder_SmallShip bldr)
        {
            BotTemplate newTemplate = new BotTemplate();
            MyMwcObjectBuilder_SmallShip_Bot botBuilder = bldr as MyMwcObjectBuilder_SmallShip_Bot;
            System.Diagnostics.Debug.Assert(botBuilder != null);

            newTemplate.m_builder = new MyMwcObjectBuilder_SmallShip_Bot(
                bldr.ShipType,
                bldr.Inventory,
                bldr.Weapons,
                bldr.Engine,
                bldr.AssignmentOfAmmo,
                bldr.Armor,
                bldr.Radar,
                bldr.ShipMaxHealth,
                bldr.ShipHealthRatio,
                bldr.ArmorHealth,
                bldr.Oxygen,
                bldr.Fuel,
                bldr.ReflectorLight,
                bldr.ReflectorLongRange,
                bldr.Faction,
                botBuilder != null ? botBuilder.AITemplate : MyAITemplateEnum.DEFAULT,
                botBuilder != null ? botBuilder.Aggressivity : 0,
                botBuilder != null ? botBuilder.SeeDistance : 1000,
                botBuilder != null ? botBuilder.SleepDistance : 1000,
                MyPatrolMode.CYCLE,
                null,
                BotBehaviorType.IDLE,
                MyLightsConstants.MAX_SPOTLIGHT_SHADOW_RANGE, bldr.AIPriority, false, true); // faction will be assigned after spawnpoint genertation
            newTemplate.m_name = bldr.ShipType.ToString();
            int key = m_selectShipsListbox.GetSelectedItem().Key;
            m_selectShipsListbox.RemoveItem(key);

            var itemName = MyGuiObjectBuilderHelpers.GetGuiHelper(MyMwcObjectBuilderTypeEnum.SmallShip, (int)newTemplate.m_builder.ShipType).Description;
            m_selectShipsListbox.AddItem(key, itemName);

            m_bots[key] = newTemplate;
        }
コード例 #4
0
        private void AddBot(MyMwcObjectBuilder_SmallShip bldr)
        {
            BotTemplate newTemplate = new BotTemplate();
            MyMwcObjectBuilder_SmallShip_Bot botBuilder = bldr as MyMwcObjectBuilder_SmallShip_Bot;
            System.Diagnostics.Debug.Assert(botBuilder != null);

            newTemplate.m_builder = new MyMwcObjectBuilder_SmallShip_Bot(
                bldr.ShipType,
                bldr.Inventory,
                bldr.Weapons,
                bldr.Engine,
                bldr.AssignmentOfAmmo,
                bldr.Armor,
                bldr.Radar,
                bldr.ShipMaxHealth,
                bldr.ShipHealthRatio,
                bldr.ArmorHealth,
                bldr.Oxygen,
                bldr.Fuel,
                bldr.ReflectorLight,
                bldr.ReflectorLongRange,
                bldr.Faction,
                botBuilder != null ? botBuilder.AITemplate : MyAITemplateEnum.DEFAULT,
                botBuilder != null ? botBuilder.Aggressivity : 0,
                botBuilder != null ? botBuilder.SeeDistance : 1000,
                botBuilder != null ? botBuilder.SleepDistance : 1000,
                MyPatrolMode.CYCLE,
                null,
                BotBehaviorType.IDLE,
                MyLightsConstants.MAX_SPOTLIGHT_SHADOW_RANGE, 0, false, true); // faction will be assigned after spawnpoint genertation
            MyGuiObjectBuilderHelpers.GetGuiHelper(MyMwcObjectBuilderTypeEnum.SmallShip, (int)bldr.ShipType);
            //m_comboItems.AddItem(i, MyGuiObjectBuilderHelpers.GetGuiHelper(MyMwcObjectBuilderTypeEnum.SmallShip, bldr.ShipType);

            //  MyMwcObjectBuilderTypeEnum.SmallShip, (int)m_inventory.SmallShips[i]).Description);

            newTemplate.m_name = ((MyGuiSmallShipHelperSmallShip)MyGuiObjectBuilderHelpers.GetGuiHelper(MyMwcObjectBuilderTypeEnum.SmallShip, (int)bldr.ShipType)).Name.ToString();//bldr.ShipType.ToString();

            // find nearest new non template index
            int index = -1;
            foreach (int key in m_bots.Keys)
            {
                if (index < key && key < TEMPLATE_INDEX_OFFSET)
                {
                    index = key;
                }
            }
            index++;

            AddBot(index, newTemplate);

        }
コード例 #5
0
 private void AddBot(int key, BotTemplate btmp)
 {
     String bld = GenerateNameFromBotTemplate(btmp);
     m_bots[key] = btmp;
     m_selectShipsListbox.AddItem(key, new StringBuilder(bld), null);
 }
コード例 #6
0
 private String GenerateNameFromBotTemplate(BotTemplate btmp)
 {
     return btmp.m_name + " "/* + btmp.m_minCount.ToString() + " - " + btmp.m_maxCount.ToString()*/;
 }
コード例 #7
0
        public virtual void Init(string hudLabelText, MyMwcObjectBuilder_SpawnPoint objectBuilder, Matrix matrix)
        {
            Visible = MyGuiScreenGamePlay.Static == null || !MyGuiScreenGamePlay.Static.IsGameActive();

            StringBuilder hudLabelTextSb = (hudLabelText == null) ? null : new StringBuilder(hudLabelText);

            base.Init(hudLabelTextSb, objectBuilder);
            m_botTemplates = new List <BotTemplate>();
            CastShadows    = false;

            SpawnInGroups          = objectBuilder.SpawnInGroups;
            LeftToSpawn            = objectBuilder.SpawnCount;
            MaxSpawnCount          = LeftToSpawn;
            FirstSpawnTimer        = objectBuilder.FirstSpawnTimer;
            RespawnTimer           = objectBuilder.RespawnTimer;
            BoundingSphereRadius   = objectBuilder.BoundingRadius;
            PatrolMode             = objectBuilder.PatrolMode;
            m_wayPointPath         = objectBuilder.WayPointPath;
            m_allKilledEventRaised = false;

            foreach (MyMwcObjectBuilder_SmallShip_Bot shipBuilder in objectBuilder.ShipTemplates)
            {
                // Disable names on spawned bots (in this way, thay can be changed when faction changes)
                shipBuilder.DisplayName = null;

                Bot nb = new Bot();
                nb.Ship    = null;
                nb.Builder = shipBuilder;

                nb.SpawnTime    = MyMinerGame.TotalGamePlayTimeInMilliseconds;
                nb.FirstSpawned = false;
                m_botShips.Add(nb);
                BotTemplate bt = new BotTemplate();
                bt.m_builder = shipBuilder;
                bt.m_name    = "";
                m_botTemplates.Add(bt);
            }

            this.LocalVolume = new BoundingSphere(Vector3.Zero, objectBuilder.BoundingRadius);

            if (Physics == null)
            {
                base.InitSpherePhysics(MyMaterialType.GLASS, WorldMatrix.Translation, BoundingSphereRadius, 1.0f, 1.0f, MyConstants.COLLISION_LAYER_UNCOLLIDABLE, RigidBodyFlag.RBF_RBO_STATIC);
            }

            VisibleInGame = false;
            Flags        |= EntityFlags.EditableInEditor;

            Faction = objectBuilder.Faction;

            SetWorldMatrix(matrix);
            NeedsUpdate = true;

            if (objectBuilder.Activated)
            {
                Activate();
            }
            else
            {
                Deactivate();
            }

            m_spawnFailedTime = null;
        }
コード例 #8
0
ファイル: MySpawnPoint.cs プロジェクト: Bunni/Miner-Wars-2081
        public virtual void Init(string hudLabelText, MyMwcObjectBuilder_SpawnPoint objectBuilder, Matrix matrix)
        {
            Visible = MyGuiScreenGamePlay.Static == null || !MyGuiScreenGamePlay.Static.IsGameActive();

            StringBuilder hudLabelTextSb = (hudLabelText == null) ? null : new StringBuilder(hudLabelText);
            base.Init(hudLabelTextSb, objectBuilder);
            m_botTemplates = new List<BotTemplate>();
            CastShadows = false;

            SpawnInGroups = objectBuilder.SpawnInGroups;
            LeftToSpawn = objectBuilder.SpawnCount;
            MaxSpawnCount = LeftToSpawn;
            FirstSpawnTimer = objectBuilder.FirstSpawnTimer;
            RespawnTimer = objectBuilder.RespawnTimer;
            BoundingSphereRadius = objectBuilder.BoundingRadius;
            PatrolMode = objectBuilder.PatrolMode;
            m_wayPointPath = objectBuilder.WayPointPath;
            m_allKilledEventRaised = false;

            foreach (MyMwcObjectBuilder_SmallShip_Bot shipBuilder in objectBuilder.ShipTemplates)
            {
                // Disable names on spawned bots (in this way, thay can be changed when faction changes)
                shipBuilder.DisplayName = null;

                Bot nb = new Bot();
                nb.Ship = null;
                nb.Builder = shipBuilder;

                nb.SpawnTime = MyMinerGame.TotalGamePlayTimeInMilliseconds;
                nb.FirstSpawned = false;
                m_botShips.Add(nb);
                BotTemplate bt = new BotTemplate();
                bt.m_builder = shipBuilder;
                bt.m_name = "";
                m_botTemplates.Add(bt);
            }

            this.LocalVolume = new BoundingSphere(Vector3.Zero, objectBuilder.BoundingRadius);

            if (Physics == null)
            {
                base.InitSpherePhysics(MyMaterialType.GLASS, WorldMatrix.Translation, BoundingSphereRadius, 1.0f, 1.0f, MyConstants.COLLISION_LAYER_UNCOLLIDABLE, RigidBodyFlag.RBF_RBO_STATIC);
            }

            VisibleInGame = false;
            Flags |= EntityFlags.EditableInEditor;

            Faction = objectBuilder.Faction;

            SetWorldMatrix(matrix);
            NeedsUpdate = true;

            if (objectBuilder.Activated)
            {
                Activate();
            }
            else
            {
                Deactivate();
            }

            m_spawnFailedTime = null;
        }