示例#1
0
        public void Reset()
        {
            // Remove also dead bots
            foreach (var bot in MyBotCoordinator.GetBots())
            {
                if (EntityId.HasValue && bot.OwnerId == EntityId.Value.NumericValue && bot.IsDead())
                {
                    bot.MarkForClose();
                }
            }

            foreach (var bot in m_botShips)
            {
                if (bot.Ship != null && !bot.Ship.Closed)
                {
                    bot.Ship.MarkForClose();
                }
                bot.Ship         = null;
                bot.SpawnTime    = MyMinerGame.TotalGamePlayTimeInMilliseconds;
                bot.FirstSpawned = false;
            }
            LeftToSpawn = MaxSpawnCount;

            m_allKilledEventRaised = false;
            FirstSpawnDone         = false;
        }
示例#2
0
        public static void MakeEnemy(MyMwcObjectBuilder_FactionEnum shipFaction)
        {
            // Order bots to kill player
            foreach (var bot in MyBotCoordinator.GetBots())
            {
                var relation = MyFactions.GetFactionsRelation(shipFaction, bot.Faction);
                if (relation == MyFactionRelationEnum.Friend || relation == MyFactionRelationEnum.Neutral)
                {
                    bot.Attack(MySession.PlayerShip);
                }
            }

            MyScriptWrapper.SetPlayerFaction(MyMwcObjectBuilder_FactionEnum.Freelancers);


            MyMissions.DisableSaveObjectives();
        }
示例#3
0
        public void Start(Vector3 position, Vector3 initialVelocity, Vector3 direction, float impulseMultiplier, MyEntity owner)
        {
            base.Start(position, initialVelocity, direction, impulseMultiplier, owner);

            m_hologramState = HologramState.Deactivated;

            if (!TimeToActivate.HasValue)
            {
                TimeToActivate = MyHologramConstants.TIME_TO_ACTIVATE;
            }

            foreach (var bot in MyBotCoordinator.GetBots())
            {
                if (bot.CanSeeTarget(owner))
                {
                    m_awareBots.Add(bot);
                }
            }
        }
示例#4
0
        private static void Save(MyGuiScreenInventory sender, MyGuiScreenInventorySaveResult saveResult)
        {
            // save money
            if (m_tradeForMoney)
            {
                m_player.Money = saveResult.Money;
            }

            bool isTradingWithMotherShip = IsTradingWithMothership();

            List <MyInventoryItem> itemsToMothership = new List <MyInventoryItem>();

            // save ships
            for (int i = 0; i < saveResult.SmallShipsObjectBuilders.Count; i++)
            {
                MyMwcObjectBuilder_SmallShip shipBuilder = saveResult.SmallShipsObjectBuilders[i].Builder;
                if (i == saveResult.CurrentIndex)
                {
                    if (m_curentIndex == saveResult.CurrentIndex)
                    {
                        // we want init weapons only when weapons are not same
                        if (!WeaponBuildersAreSame(m_player.Ship.Weapons.GetWeaponsObjectBuilders(true), shipBuilder.Weapons))
                        {
                            m_player.Ship.Weapons.Init(shipBuilder.Weapons, shipBuilder.AssignmentOfAmmo);
                        }
                        m_player.Ship.Inventory.Init(shipBuilder.Inventory);
                        m_player.Ship.Armor  = shipBuilder.Armor;
                        m_player.Ship.Engine = shipBuilder.Engine;
                    }
                    else
                    {
                        var oldShip = m_player.Ship;
                        m_player.Ship.MarkForClose();

                        if (MyMultiplayerGameplay.IsRunning)
                        {
                            MyMultiplayerGameplay.Static.Respawn(shipBuilder, m_player.Ship.WorldMatrix);
                        }
                        else
                        {
                            var ship = MyEntities.CreateFromObjectBuilderAndAdd(null, shipBuilder, m_player.Ship.WorldMatrix);
                        }

                        // Update bots - bot logic runs on host
                        MyBotCoordinator.ChangeShip(oldShip, m_player.Ship);
                    }
                }
                else
                {
                    if (isTradingWithMotherShip)
                    {
                        MyInventoryItem shipInventoryItem = MyInventory.CreateInventoryItemFromObjectBuilder(shipBuilder);
                        itemsToMothership.Add(shipInventoryItem);
                        //m_shipsInventoryOwner.Inventory.AddInventoryItem(shipInventoryItem);
                    }
                }
            }

            // save other side inventory
            if (m_inventoryScreenType != MyGuiScreenInventoryType.GodEditor)
            {
                if (m_otherSideInventoryOwner != null)
                {
                    if (isTradingWithMotherShip)
                    {
                        for (int i = saveResult.OtherSideInventoryObjectBuilder.InventoryItems.Count - 1; i >= 0; i--)
                        {
                            MyMwcObjectBuilder_InventoryItem itemBuilder = saveResult.OtherSideInventoryObjectBuilder.InventoryItems[i];
                            if (itemBuilder.IsTemporaryItem)
                            {
                                saveResult.OtherSideInventoryObjectBuilder.InventoryItems.RemoveAt(i);
                                // because smallships was added when ships were saved
                                if (itemBuilder.ItemObjectBuilder.GetObjectBuilderType() != MyMwcObjectBuilderTypeEnum.SmallShip_Player)
                                {
                                    itemsToMothership.Add(MyInventory.CreateInventoryItemFromInventoryItemObjectBuilder(itemBuilder));
                                }
                            }
                        }
                    }
                    m_otherSideInventoryOwner.Inventory.Init(saveResult.OtherSideInventoryObjectBuilder);
                }
            }

            if (isTradingWithMotherShip)
            {
                m_shipsInventoryOwner.Inventory.AddInventoryItems(itemsToMothership);
            }
        }