Пример #1
0
	protected override SpawnInfo GetNextSpawn()
	{
		var spawn = new SpawnInfo();

		if (Random(100) < 50)
		{
			white = true;
			spawn.BossName = L("Giant White Wolf");
		}
		else
		{
			white = false;
			spawn.BossName = L("Giant Black Wolf");
		}

		if (Random(100) < 50)
		{
			spawn.LocationName = L("Southern Fields of Tir Chonaill");
			spawn.Location = new Location("Uladh_main/field_Tir_S_aa/TirChonaill_monster3");
		}
		else
		{
			spawn.LocationName = L("Eastern Fields of Tir Chonaill");
			spawn.Location = new Location("Uladh_main/field_Tir_E_ba/TirChonaill_monster6");
		}

		spawn.Time = DateTime.Now.AddHours(Random(3, 6));
		spawn.LifeSpan = TimeSpan.FromMinutes(20);

		return spawn;
	}
Пример #2
0
    // Called when player connects with their phone
    void InitializeNetPlayer(SpawnInfo spawnInfo)
    {
        Init();

        m_netPlayer = spawnInfo.netPlayer;
        m_netPlayer.OnDisconnect += Remove;
        m_netPlayer.OnNameChange += ChangeName;

        // Setup events for the different messages.
        m_netPlayer.RegisterCmdHandler<MessageMove>("move", OnMove);
        m_netPlayer.RegisterCmdHandler<MessageJump>("jump", OnJump);

        SetName(m_netPlayer.Name);

        // Pick a random amount to adjust the hue and saturation
        float hue = Random.value;
        float sat = (float)Random.Range(0, 3) * -0.25f;
        MessageSetColor color = new MessageSetColor(
            hue,
            sat,
            0.0f,
            m_material.GetFloat("_HSVRangeMin"),
            m_material.GetFloat("_HSVRangeMax"));
        SetColor(color);

        // Send it to the phone
        m_netPlayer.SendCmd("setColor", color);
    }
Пример #3
0
	public override bool Init()
	{
		Spawn = new SpawnInfo();

		Load();
		PrepareSpawn();

		return true;
	}
Пример #4
0
	private void PrepareSpawn()
	{
		Spawn = GetNextSpawn();
		_droppedScroll = false;

		var delay = GetTimeUntilSpawn();
		Task.Delay(delay).ContinueWith(a =>
		{
			if (_disposed)
				return;

			SpawnAll();
		});
	}
	protected override SpawnInfo GetNextSpawn()
	{
		var spawn = new SpawnInfo();

		if (Random(100) < 50)
		{
			ogre = true;
			spawn.BossName = L("Giant Ogre");
		}
		else
		{
			ogre = false;
			spawn.BossName = L("Black Wizard");
		}

		switch (Random(6))
		{
			case 0:
				spawn.LocationName = L("Reighinalt");
				spawn.Location = new Location("Ula_Dun_to_Bangor/Field_DunBan_S2/mon64");
				break;
			case 1:
				spawn.LocationName = L("Dragon Statue Excavation Site");
				spawn.Location = new Location("Ula_Dun_to_Bangor/Field_DunBan_Center/mon57");
				break;
			case 2:
				spawn.LocationName = L("Path to Dunbarton");
				spawn.Location = new Location("Ula_Dun_to_Bangor/Field_DunBan_N4/mon52");
				break;
			case 3:
				spawn.LocationName = L("Eastern Fields of Gairech");
				spawn.Location = new Location("Ula_Dun_to_Bangor/Field_DunBan_N3/mon53");
				break;
			case 4:
				spawn.LocationName = L("Eastern Fields of Gairech");
				spawn.Location = new Location("Ula_Dun_to_Bangor/Field_DunBan_N3/mon54");
				break;
			case 5:
				spawn.LocationName = L("Eastern Fields of Gairech");
				spawn.Location = new Location("Ula_Dun_to_Bangor/Field_DunBan_N3/mon55");
				break;
		}

		spawn.Time = DateTime.Now.AddHours(Random(3, 6));
		spawn.LifeSpan = TimeSpan.FromMinutes(20);

		return spawn;
	}
    // Returns true if we collided with anything
    bool CollidedWithObject(SpawnInfo objToSpawnInfo)
    {
        // If the spawn location is at origin, dont spawn an object
        if(Vector3.Equals(objToSpawnInfo.spawnLocation, Vector3.zero)){
          return true;
        }

        var hitColliders = Physics2D.OverlapCircleAll(objToSpawnInfo.spawnLocation,
                                                  objToSpawnInfo.radius, spawnLayers);
        //OnDrawGizmos();
        if(hitColliders.Length > 0){
           return true;
        }

        return false;
    }
Пример #7
0
	public GameObject flyGuy;		// a reference to the FlyGuy Prefab GameObejct
	
	void InitializeNetPlayer(SpawnInfo spawnInfo) 
	{
		NetPlayer m_netPlayer = spawnInfo.netPlayer;

		GameObject newChar;
		if (!GameObject.FindWithTag ("Mario")) 
			newChar = Instantiate(mario);
		else if (!GameObject.FindWithTag ("Luigi")) 
			newChar = Instantiate(luigi);
		else if (!GameObject.FindWithTag ("PurpleMario")) 
			newChar = Instantiate(purpleMario);
		else if (!GameObject.FindWithTag ("YellowLuigi")) 
			newChar = Instantiate(yellowLuigi);
		else 
			newChar = Instantiate(flyGuy);

		newChar.GetComponent<HFTGamepad>().InitializeNetPlayer (m_netPlayer);
		Destroy (this.gameObject);
	}
	protected override SpawnInfo GetNextSpawn()
	{
		var spawn = new SpawnInfo();

		if (Random(100) < 50)
		{
			goblin = true;
			spawn.BossName = L("Goblin Bandit");
		}
		else
		{
			goblin = false;
			spawn.BossName = L("Black Raccoon");
		}

		switch (Random(4))
		{
			case 0:
				spawn.LocationName = L("North Eastern Fields of Dunbarton");
				spawn.Location = new Location("Uladh_Dunbarton/field_Dunbarton_02/dunbmon33");
				break;
			case 1:
				spawn.LocationName = L("Southern Fields of Dunbarton");
				spawn.Location = new Location("Uladh_Dunbarton/field_Dunbarton_p3/dunbmon40");
				break;
			case 2:
				spawn.LocationName = L("North Eastern Fields of Dunbarton");
				spawn.Location = new Location("Uladh_Dunbarton/field_Dunbarton_02/dunbmon47");
				break;
			case 3:
				spawn.LocationName = L("Eastern Fields of Dunbarton");
				spawn.Location = new Location("Uladh_Dunbarton/field_Dunbarton_05/dunbmon35");
				break;
		}

		spawn.Time = DateTime.Now.AddHours(Random(3, 6));
		spawn.LifeSpan = TimeSpan.FromMinutes(20);

		return spawn;
	}
	protected override SpawnInfo GetNextSpawn()
	{
		var spawn = new SpawnInfo();

		if (Random(100) < 50)
		{
			bear = true;
			spawn.BossName = L("Giant Bear");
		}
		else
		{
			bear = false;
			spawn.BossName = L("Black Warrior");
		}

		switch (Random(4))
		{
			case 0:
				spawn.LocationName = L("South Eastern Fields of Dugald Aisle");
				spawn.Location = new Location("Uladh_Dun_to_Tircho/Field_DunTir_06/dugaldmon25a");
				break;
			case 1:
				spawn.LocationName = L("South Western Fields of Dugald Aisle");
				spawn.Location = new Location("Uladh_Dun_to_Tircho/Field_DunTir_01/dugaldmon23");
				break;
			case 2:
				spawn.LocationName = L("Southern Path of Dugald Aisle");
				spawn.Location = new Location("Uladh_Dun_to_Tircho/Field_DunTir_07/dugaldmon22");
				break;
			case 3:
				spawn.LocationName = L("Ulaid Logging Camp");
				spawn.Location = new Location("Uladh_Dun_to_Tircho/Field_DunTir_11/dugaldmon27");
				break;
		}

		spawn.Time = DateTime.Now.AddHours(Random(3, 6));
		spawn.LifeSpan = TimeSpan.FromMinutes(20);

		return spawn;
	}
Пример #10
0
        public void SpawnCreature(uint race, uint amount, uint region, MabiVertex pos, uint radius = 0, bool effect = false)
        {
            var spawn = new SpawnInfo();
            spawn.Amount = amount;
            spawn.RaceId = race;
            spawn.Region = region;

            if (radius == 0)
            {
                spawn.SpawnType = SpawnLocationType.Point;
                spawn.SpawnPoint = new Point(pos.X, pos.Y);
            }
            else
            {
                spawn.SpawnType = SpawnLocationType.Polygon;
                spawn.SpawnPolyRegion = new SpawnRegion(new Point[]
                {
                    new Point(pos.X - radius, pos.Y - radius),
                    new Point(pos.X - radius, pos.Y + radius),
                    new Point(pos.X + radius, pos.Y + radius),
                    new Point(pos.X + radius, pos.Y - radius),
                });
                spawn.SpawnPolyBounds = spawn.SpawnPolyRegion.GetBounds();
            }

            ScriptManager.Instance.Spawn(spawn, 0, effect);
        }
Пример #11
0
    /// <summary>
    /// Spawns a ghost for the indicated mind's body and transfers the connection's control to it.
    /// </summary>
    /// <param name="conn"></param>
    /// <param name="oldBody"></param>
    /// <param name="characterSettings"></param>
    /// <param name="occupation"></param>
    /// <returns></returns>
    public static void ServerSpawnGhost(Mind forMind)
    {
        if (forMind == null)
        {
            Logger.LogError("Mind was null for ServerSpawnGhost", Category.Server);
            return;
        }
        //determine where to spawn the ghost
        var body = forMind.GetCurrentMob();

        if (body == null)
        {
            Logger.LogError("Body was null for ServerSpawnGhost", Category.Server);
            return;
        }

        var settings     = body.GetComponent <PlayerScript>().characterSettings;
        var connection   = body.GetComponent <NetworkIdentity>().connectionToClient;
        var registerTile = body.GetComponent <RegisterTile>();

        if (registerTile == null)
        {
            Logger.LogErrorFormat("Cannot spawn ghost for body {0} because it has no registerTile", Category.ItemSpawn,
                                  body.name);
            return;
        }

        Vector3Int spawnPosition = TransformState.HiddenPos;
        var        objBeh        = body.GetComponent <ObjectBehaviour>();

        if (objBeh != null)
        {
            spawnPosition = objBeh.AssumedWorldPositionServer().RoundToInt();
        }

        if (spawnPosition == TransformState.HiddenPos)
        {
            //spawn ghost at occupation location if we can't determine where their body is
            Transform spawnTransform = GetSpawnForJob(forMind.occupation.JobType);
            if (spawnTransform == null)
            {
                Logger.LogErrorFormat("Unable to determine spawn position for occupation {1}. Cannot spawn ghost.", Category.ItemSpawn,
                                      forMind.occupation.DisplayName);
                return;
            }

            spawnPosition = spawnTransform.transform.position.CutToInt();
        }

        var matrixInfo      = MatrixManager.AtPoint(spawnPosition, true);
        var parentNetId     = matrixInfo.NetID;
        var parentTransform = matrixInfo.Objects;

        //using parentTransform.rotation rather than Quaternion.identity because objects should always
        //be upright w.r.t.  localRotation, NOT world rotation
        var ghost = Object.Instantiate(CustomNetworkManager.Instance.ghostPrefab, spawnPosition, parentTransform.rotation,
                                       parentTransform);

        ghost.GetComponent <PlayerScript>().registerTile.ServerSetNetworkedMatrixNetID(parentNetId);

        forMind.Ghosting(ghost);

        ServerTransferPlayer(connection, ghost, body, EVENT.GhostSpawned, settings);


        //fire all hooks
        var info = SpawnInfo.Ghost(forMind.occupation, settings, CustomNetworkManager.Instance.ghostPrefab,
                                   SpawnDestination.At(spawnPosition, parentTransform));

        Spawn._ServerFireClientServerSpawnHooks(SpawnResult.Single(info, ghost));
    }
Пример #12
0
 public void OnSpawnServer(SpawnInfo info)
 {
     IsBurning = isBurningOnSpawn;
 }
Пример #13
0
 /// <summary>
 /// Spawns the entity <paramref name="entity"/> at <paramref name="spawnInfo"/>
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="spawnInfo"></param>
 /// <returns></returns>
 public GameObject Spawn(BattleEntityInfo entity, SpawnInfo spawnInfo)
 {
     return(Configure(entity.Instantiate(), spawnInfo));
 }
Пример #14
0
 public void OnSpawnServer(SpawnInfo info)
 {
     SyncPhotocopierState(photocopierState, photocopierState);
 }
Пример #15
0
        public override void BeforeStart()
        {
            base.BeforeStart();

            if (m_obForLoading == null) return;

            int currentTime = MySandboxGame.TotalGamePlayTimeInMilliseconds;

            m_allSpawnInfos.Capacity = m_obForLoading.SpawnInfos.Count;
            foreach (var info in m_obForLoading.SpawnInfos)
            {
                var spawnInfo = new SpawnInfo(info, currentTime);
                m_allSpawnInfos.Add(spawnInfo);
                m_spawnInfoGrid.AddPoint(ref spawnInfo.Position, spawnInfo);
            }

            m_allTimeoutInfos.Capacity = m_obForLoading.TimeoutInfos.Count;
            foreach (var info in m_obForLoading.TimeoutInfos)
            {
                var timeoutInfo = new SpawnTimeoutInfo(info, currentTime);
                if (timeoutInfo.AnimalSpawnInfo == null) // do not add invalid timeout objects
                    continue;
                m_allTimeoutInfos.Add(timeoutInfo);
                m_timeoutInfoGrid.AddPoint(ref timeoutInfo.Position, timeoutInfo);
            }

            m_obForLoading = null;
        }
Пример #16
0
 public static string ParseSpawn(SpawnInfo spawnInfo)
 {
     return spawnInfo.id + SPLIT_DATA.ToString()
         + (int)spawnInfo.right + SPLIT_DATA.ToString()
         + (int)spawnInfo.up + SPLIT_DATA.ToString()
         + (int)spawnInfo.forward;
 }
Пример #17
0
 public void OnSpawnServer(SpawnInfo info)
 {
     Init();
 }
Пример #18
0
 public void OnSpawnServer(SpawnInfo info)
 {
     SyncCharges(startCharges, startCharges);
 }
Пример #19
0
 public void OnSpawnServer(SpawnInfo info)
 {
     GetComponent <ClosetControl>().ServerToggleClosed(false);
 }
Пример #20
0
        public void OnSpawnServer(SpawnInfo info)
        {
            var registerTile = GetComponent <RegisterTile>();

            registerTile.WaitForMatrixInit(RollRandomPool);
        }
Пример #21
0
 public void OnSpawnServer(SpawnInfo info)
 {
     EnsureInit();
 }
Пример #22
0
 public void OnSpawnServer(SpawnInfo info)
 {
     SetupInitialValues();
 }
Пример #23
0
 public override void OnSpawnServer(SpawnInfo info)
 {
     base.OnSpawnServer(info);
     eatFoodSound = CommonSounds.Instance.EatFood;
 }
Пример #24
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="info"></param>
        /// <param name="amount">SpawnInfo.Amount used if 0. Needed for respawning.</param>
        /// <param name="effect"></param>
        /// <returns>Amount of creatures spawned</returns>
        public int Spawn(SpawnInfo info, uint amount = 0, bool effect = false)
        {
            var result = 0;

            var rand = RandomProvider.Get();

            var raceInfo = MabiData.RaceDb.Find(info.RaceId);
            if (raceInfo == null)
            {
                Logger.Warning("Race not found: " + info.RaceId.ToString());
                return 0;
            }

            string aiFilePath = null;
            if (!string.IsNullOrEmpty(raceInfo.AI))
            {
                aiFilePath = Path.Combine(WorldConf.ScriptPath, "ai", raceInfo.AI + ".cs");
                if (!File.Exists(aiFilePath))
                {
                    Logger.Warning("AI script '" + raceInfo.AI + ".cs' couldn't be found.");
                    aiFilePath = null;
                }
            }

            if (amount == 0)
                amount = info.Amount;

            for (int i = 0; i < amount; ++i)
            {
                var monster = new MabiNPC();
                monster.SpawnId = info.Id;
                monster.Name = raceInfo.Name;
                var loc = info.GetRandomSpawnPoint(rand);
                monster.SetLocation(info.Region, loc.X, loc.Y);
                monster.AnchorPoint = new MabiVertex(loc.X, loc.Y);
                monster.Color1 = raceInfo.ColorA;
                monster.Color2 = raceInfo.ColorB;
                monster.Color3 = raceInfo.ColorC;
                monster.Height = raceInfo.Size;
                monster.LifeMaxBase = raceInfo.Life;
                monster.Life = raceInfo.Life;
                monster.Race = raceInfo.Id;
                monster.BattleExp = raceInfo.Exp;
                monster.Direction = (byte)rand.Next(256);
                monster.State &= ~CreatureStates.GoodNpc; // Use race default?
                monster.GoldMin = raceInfo.GoldMin;
                monster.GoldMax = raceInfo.GoldMax;
                monster.Drops = raceInfo.Drops;

                foreach (var skill in raceInfo.Skills)
                {
                    monster.Skills.Add(new MabiSkill(skill.SkillId, skill.Rank, monster.Race));
                }

                monster.LoadDefault();

                // Missing stat data?
                if (monster.Life < 1)
                    monster.Life = monster.LifeMaxBase = 10;

                try
                {
                    if (aiFilePath != null)
                    {
                        var aiscriptAsm = this.GetScript(aiFilePath);
                        if (aiscriptAsm != null)
                        {
                            var types = aiscriptAsm.GetTypes().Where(t => t.IsSubclassOf(typeof(AIScript)));
                            monster.AIScript = Activator.CreateInstance(types.First()) as AIScript;
                            monster.AIScript.Creature = monster;
                            monster.AIScript.OnLoad();
                            monster.AIScript.Activate(0); // AI is intially active
                        }
                        else
                        {
                            raceInfo.AI = null; // Suppress future attempts to load this AI
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Exception(ex);
                }

                monster.AncientEligible = true;
                monster.AncientTime = DateTime.Now.AddMinutes(WorldConf.TimeBeforeAncient);

                WorldManager.Instance.AddCreature(monster);

                if (effect)
                    WorldManager.Instance.Broadcast(PacketCreator.SpawnEffect(monster, SpawnEffect.Monster), SendTargets.Range, monster);

                result++;
            }

            return result;
        }
Пример #25
0
 public void OnSpawnServer(SpawnInfo info)
 {
     foodToBeProcessed = new Queue <GrownFood>();
     seedPackets       = new List <SeedPacket>();
 }
Пример #26
0
 // This gives you a chance to send that player's phone
 // a command to tell it to display "The game is full" or
 // whatever you want.
 //
 // Note: You can call PlayerSpawner.ReturnPlayer to eject
 // a player from their slot and get a new player for that slot
 // If you do that this function will be called for the returned
 // player.
 //
 // Simiarly you can call PlayerSpawner.FlushCurrentPlayers to
 // eject all current players in which case this will be called
 // for all players that were player.
 void WaitingNetPlayer(SpawnInfo spawnInfo)
 {
     // Tell the controller to display full message
     spawnInfo.netPlayer.SendCmd("full");
 }
Пример #27
0
 public void OnSpawnServer(SpawnInfo info)
 {
     ServerCheckStandingChange(false);
 }
Пример #28
0
        public override void UpdateAfterSimulation()
        {
            base.UpdateAfterSimulation();

            if (!Sync.IsServer) return;

            if (MyDebugDrawSettings.ENABLE_DEBUG_DRAW && MyDebugDrawSettings.DEBUG_DRAW_FAUNA_COMPONENT)
            {
                DebugDraw();
            }

            ProfilerShort.Begin("MySpaceFaunaComponent.UpdateAfter");

            m_waitForUpdate--;
            if (m_waitForUpdate > 0)
            {
                return;
            }
            m_waitForUpdate = UPDATE_DELAY;

            var players = Sync.Players.GetOnlinePlayers();
            m_tmpPlayerPositions.Capacity = Math.Max(m_tmpPlayerPositions.Capacity, players.Count);
            m_tmpPlayerPositions.Clear();

            // Reset bot numbers
            foreach (var planet in m_planets)
            {
                planet.Value.BotNumber = 0;
            }

            // Update bot numbers and save player positions
            foreach (var player in players)
            {
                // Human player
                if (player.Id.SerialId == 0)
                {
                    if (player.Controller.ControlledEntity == null) continue;
                    var pos = player.GetPosition();
                    m_tmpPlayerPositions.Add(pos);
                }
                // Bot
                else
                {
                    if (player.Controller.ControlledEntity == null) continue;
                    var pos = player.GetPosition();

                    var planet = MyGamePruningStructure.GetClosestPlanet(pos);
                    if (planet != null)
                    {
                        PlanetAIInfo planetInfo;
                        if (m_planets.TryGetValue(planet.EntityId, out planetInfo))
                        {
                            planetInfo.BotNumber++;
                        }
                    }
                }
            }

            int currentTime = MySandboxGame.TotalGamePlayTimeInMilliseconds;

            // Spawn bots near players on planets, only if in survival/myfakes macro set
            if (MyFakes.SPAWN_SPACE_FAUNA_IN_CREATIVE)
            {
                foreach (var player in players)
                {

                    if (player.Controller.ControlledEntity == null)
                        continue;

                    var pos = player.GetPosition();
                    var planet = MyGamePruningStructure.GetClosestPlanet(pos);
                    if (planet == null || !PlanetHasFauna(planet))
                        continue;

                    PlanetAIInfo planetInfo = null;
                    if (!m_planets.TryGetValue(planet.EntityId, out planetInfo))
                        continue;

                    // Human player - spawn spiders
                    if (player.Id.SerialId == 0)
                    {
                        // Distance to surface check
                        Vector3D toSurface = planet.GetClosestSurfacePointGlobal(ref pos) - pos;
                        if (toSurface.LengthSquared() >= PROXIMITY_DIST * PROXIMITY_DIST || planetInfo.BotNumber >= MAX_BOTS_PER_PLANET)
                            continue;

                        int spawnPointCount = 0;
                        var pointEnum = m_spawnInfoGrid.GetPointsCloserThan(ref pos, SPHERE_SPAWN_DIST);
                        while (pointEnum.MoveNext())
                        {
                            var spawnPoint = pointEnum.Current;
                            spawnPointCount++;
                            if (spawnPoint.SpawnDone)
                                continue; // Don't take not-yet cleaned spawn info into consideration

                            if (spawnPoint.ShouldSpawn(currentTime))
                            {
                                spawnPoint.SpawnDone = true;
                                var timeouts = m_timeoutInfoGrid.GetPointsCloserThan(ref pos, TIMEOUT_DIST);
                                bool timeoutPresent = false;
                                while (timeouts.MoveNext())
                                {
                                    if (timeouts.Current.IsTimedOut(currentTime))
                                        continue;
                                    timeoutPresent = true;
                                    break;
                                }
                                if (timeoutPresent) continue;

                                var animalSpawnInfo = MySpaceBotFactory.GetDayOrNightAnimalSpawnInfo(planet, spawnPoint.Position);
                                if (animalSpawnInfo == null) continue;

                                int numBots = MyUtils.GetRandomInt(animalSpawnInfo.WaveCountMin, animalSpawnInfo.WaveCountMax);
                                for (int i = 0; i < numBots; ++i)
                                {
                                    SpawnBot(spawnPoint, planet, animalSpawnInfo);
                                }
                            }
                            else
                            {
                                spawnPoint.UpdateAbandoned(currentTime);
                            }
                        }

                        if (spawnPointCount == 0) // we dont have any spawn points near human players position
                        {
                            var spawnInfo = new SpawnInfo(pos, currentTime, planet);
                            m_spawnInfoGrid.AddPoint(ref pos, spawnInfo);
                            m_allSpawnInfos.Add(spawnInfo);
                        }
                    }
                    // Despawn bots that are too far from all players
                    else //if (player.Id.SteamId == Sync.MyId)
                    {
                        double closestDistSq = double.MaxValue;
                        foreach (Vector3D playerPosition in m_tmpPlayerPositions)
                        {
                            closestDistSq = Math.Min(Vector3D.DistanceSquared(pos, playerPosition), closestDistSq);
                        }

                        if (closestDistSq > DESPAWN_DIST * DESPAWN_DIST)
                        {
                            MyAIComponent.Static.RemoveBot(player.Id.SerialId, removeCharacter: true);
                        }
                    }
                }
            }
            m_tmpPlayerPositions.Clear();

            m_waitForClean -= UPDATE_DELAY;

            if (m_waitForClean <= 0)
            {
                MyAIComponent.Static.CleanUnusedIdentities();
                m_waitForClean = CLEAN_DELAY;

                for (int i = 0; i < m_allSpawnInfos.Count; ++i)
                {
                    var spawnInfo = m_allSpawnInfos[i];
                    if (spawnInfo.IsAbandoned(currentTime) || spawnInfo.SpawnDone)
                    {
                        m_allSpawnInfos.RemoveAtFast(i);
                        Vector3D point = spawnInfo.Position;
                        m_spawnInfoGrid.RemovePoint(ref point);
                        --i;
                    }
                }

                for (int i = 0; i < m_allTimeoutInfos.Count; ++i)
                {
                    var timeoutInfo = m_allTimeoutInfos[i];
                    if (timeoutInfo.IsTimedOut(currentTime))
                    {
                        m_allTimeoutInfos.RemoveAtFast(i);
                        Vector3D point = timeoutInfo.Position;
                        m_timeoutInfoGrid.RemovePoint(ref point);
                        --i;
                    }
                }
            }

            ProfilerShort.End();
        }
Пример #29
0
 public void OnSpawnServer(SpawnInfo info)
 {
     // reset vendor content to initial value
     ResetContentList();
 }
Пример #30
0
    void InitializeNetPlayer(SpawnInfo spawnInfo)
    {
        m_netPlayer = spawnInfo.netPlayer;
        m_netPlayer.OnDisconnect += HandleDisconnect;

        // Setup events for the different messages.
        m_netPlayer.RegisterCmdHandler<MessageButton>("button", HandleButton);
        m_netPlayer.RegisterCmdHandler<MessageDPad>("dpad", HandleDPad);
        m_netPlayer.RegisterCmdHandler<MessageOrient>("orient", HandleOrient);
        m_netPlayer.RegisterCmdHandler<MessageAccel>("accel", HandleAccel);
        m_netPlayer.RegisterCmdHandler<MessageRot>("rot", HandleRot);
        m_netPlayer.RegisterCmdHandler<MessageTouch>("touch", HandleTouch);

        m_playerNameManager = new HFTPlayerNameManager(m_netPlayer);
        m_playerNameManager.OnNameChange += HandleNameChange;

        // If the controller is showing the player "game full"
        // then tell it can play.
        m_netPlayer.SendCmd("play");
        SendControllerOptions();
        SendColor();
    }
Пример #31
0
 public void OnSpawnServer(SpawnInfo info)
 {
     SyncIsLayingDown(isLayingDown, false);
 }
Пример #32
0
 /* Called when being spawned from a Portal */
 void OnSpawn(SpawnInfo si)
 {
     flippedHoriz = !si.faceRight;
 }
Пример #33
0
 public virtual void OnSpawnServer(SpawnInfo info)
 {
     SyncArticleName(initialName);
     SyncArticleDescription(initialDescription);
 }
Пример #34
0
    /// <summary>
    /// Spawns a new player character and transfers the connection's control into the new body.
    /// If existingMind is null, creates the new mind and assigns it to the new body.
    ///
    /// Fires server and client side player spawn hooks.
    /// </summary>
    /// <param name="connection">connection to give control to the new player character</param>
    /// <param name="occupation">occupation of the new player character</param>
    /// <param name="characterSettings">settings of the new player character</param>
    /// <param name="existingMind">existing mind to transfer to the new player, if null new mind will be created
    /// and assigned to the new player character</param>
    /// <param name="spawnPos">world position to spawn at</param>
    /// <param name="naked">If spawning a player, should the player spawn without the defined initial equipment for their occupation?</param>
    /// <param name="willDestroyOldBody">if true, indicates the old body is going to be destroyed rather than pooled,
    /// thus we shouldn't send any network message which reference's the old body's ID since it won't exist.</param>
    ///
    /// <returns>the spawned object</returns>
    private static GameObject ServerSpawnInternal(NetworkConnection connection, Occupation occupation, CharacterSettings characterSettings,
                                                  Mind existingMind, Vector3Int?spawnPos = null, bool naked = false, bool willDestroyOldBody = false)
    {
        //determine where to spawn them
        if (spawnPos == null)
        {
            Transform spawnTransform;
            //Spawn normal location for special jobs or if less than 2 minutes passed
            if (GameManager.Instance.stationTime < ARRIVALS_SPAWN_TIME || NEVER_SPAWN_ARRIVALS_JOBS.Contains(occupation.JobType))
            {
                spawnTransform = GetSpawnForJob(occupation.JobType);
            }
            else
            {
                spawnTransform = GetSpawnForLateJoin(occupation.JobType);
                //Fallback to assistant spawn location if none found for late join
                if (spawnTransform == null && occupation.JobType != JobType.NULL)
                {
                    spawnTransform = GetSpawnForJob(JobType.ASSISTANT);
                }
            }

            if (spawnTransform == null)
            {
                Logger.LogErrorFormat(
                    "Unable to determine spawn position for connection {0} occupation {1}. Cannot spawn player.",
                    Category.ItemSpawn,
                    connection.address, occupation.DisplayName);
                return(null);
            }

            spawnPos = spawnTransform.transform.position.CutToInt();
        }

        //create the player object
        var newPlayer       = ServerCreatePlayer(spawnPos.GetValueOrDefault());
        var newPlayerScript = newPlayer.GetComponent <PlayerScript>();

        //get the old body if they have one.
        var oldBody = existingMind?.GetCurrentMob();

        //transfer control to the player object
        ServerTransferPlayer(connection, newPlayer, oldBody, EVENT.PlayerSpawned, characterSettings, willDestroyOldBody);


        if (existingMind == null)
        {
            //create the mind of the player
            Mind.Create(newPlayer, occupation);
        }
        else
        {
            //transfer the mind to the new body
            existingMind.SetNewBody(newPlayerScript);
        }


        var ps = newPlayer.GetComponent <PlayerScript>();
        var connectedPlayer = PlayerList.Instance.Get(connection);

        connectedPlayer.Name = ps.playerName;
        connectedPlayer.Job  = ps.mind.occupation.JobType;
        UpdateConnectedPlayersMessage.Send();

        //fire all hooks
        var info = SpawnInfo.Player(occupation, characterSettings, CustomNetworkManager.Instance.humanPlayerPrefab,
                                    SpawnDestination.At(spawnPos), naked: naked);

        Spawn._ServerFireClientServerSpawnHooks(SpawnResult.Single(info, newPlayer));

        return(newPlayer);
    }
Пример #35
0
 public void OnSpawnServer(SpawnInfo info)
 {
     plasteelSheetCount = 0;
 }
Пример #36
0
 public void OnSpawnServer(SpawnInfo info)
 {
     statusString = "Ready to scan.";
     SyncPowered(powered, powered);
 }
Пример #37
0
 public override void OnSpawnServer(SpawnInfo info)
 {
     base.OnSpawnServer(info);
     statusString = "Ready to scan.";
     SyncPowered(powered, powered);
 }
Пример #38
0
 public void OnSpawnServer(SpawnInfo info)
 {
     SyncIsOn(isOn, false);
 }
Пример #39
0
 public void OnSpawnServer(SpawnInfo info)
 {
     labelAmount  = LABEL_CAPACITY;
     currentLabel = "";
 }
Пример #40
0
 public void OnSpawnServer(SpawnInfo info)
 {
     RefreshSprites();
 }
Пример #41
0
    private void Load()
    {
        MapData mapData = mapDatabase.Get(s_LoadId);
        if (null == mapData)
        {
            return;
        }

        s_MagicCube.Load(mapData);
        s_DestCube = s_MagicCube.destCube;
        s_SpawnInfo = mapData.spawnInfo;
    }
Пример #42
0
    void InitializeNetPlayer(SpawnInfo spawnInfo)
    {
        MapGeneration.doDestroy += DieAnim;

        m_netPlayer = spawnInfo.netPlayer;
        m_netPlayer.OnDisconnect += Remove;

        // Setup events for the different messages.
        m_netPlayer.RegisterCmdHandler<MessageButton>("button", HandleButton);
        m_netPlayer.RegisterCmdHandler<MessageDPad>("dpad", HandleDPad);
        m_netPlayer.RegisterCmdHandler<MessageOrient>("orient", HandleOrient);
        m_netPlayer.RegisterCmdHandler<MessageAccel>("accel", HandleAccel);
        m_netPlayer.RegisterCmdHandler<MessageRot>("rot", HandleRot);
        m_netPlayer.RegisterCmdHandler<MessageTouch>("touch", HandleTouch);

        m_netPlayer.OnNameChange += ChangeName;

        // If the controller is showing the player "game full"
        // then tell it can play.
        m_netPlayer.SendCmd("play");
        SendControllerOptions();
        SendColor();

        //COLOR
        MeshRenderer rend = this.gameObject.GetComponent<MeshRenderer>();
        Material mat = new Material(Shader.Find("Standard"));
        mat.color = m_color;
        rend.material = mat;

        //SPAWNING
        MapGeneration map = GameObject.FindWithTag ("Map").GetComponent<MapGeneration> ();
        int xSpawnPos = Random.Range(map.size - 3, map.size - 1);
        int ySpawnPos = Random.Range(map.size - 3, map.size - 1);
        this.gameObject.transform.position = new Vector3 (xSpawnPos,
                                                          map.getHeight (xSpawnPos, ySpawnPos) + 1.5f, // stop harcoding shit, amir
                                                         ySpawnPos);
        onCreate(this.gameObject);
        PlayerMovement.onSpawn += delegate(ref Vector2 currentCell) {
            currentCell.x = xSpawnPos;
            currentCell.y = ySpawnPos;
        };
    }
Пример #43
0
 public void OnSpawnServer(SpawnInfo info)
 {
     EnsureInit();
     SetSpriteAndScatter(Random.Range(0, spriteHandler.CatalogueCount));
 }
Пример #44
0
	protected override SpawnInfo GetNextSpawn()
	{
		var spawn = new SpawnInfo();
		spawn.BossName = L("Pillow Fighters");
		spawn.Time = ErinnTime.GetNextTime(19, 0).DateTime;
		spawn.LifeSpan = TimeSpan.FromMinutes(6);

		return spawn;
	}
Пример #45
0
 void InitializeNetPlayer(SpawnInfo spawnInfo)
 {
     m_netPlayer = spawnInfo.netPlayer;
     score.caughtEvent += delegate (){spawnInfo.netPlayer.SendCmd ("customText", new CustomTextParcel(GetPhoneChasingText()));};
     score.catchPlayerEvent += delegate (){spawnInfo.netPlayer.SendCmd ("customText", new CustomTextParcel(GetPhoneChasingText()));};
 }
Пример #46
0
        private void SpawnBot(SpawnInfo spawnInfo, MyPlanet planet, MyPlanetAnimalSpawnInfo animalSpawnInfo)
        {          
            PlanetAIInfo planetInfo = null;
            if (!m_planets.TryGetValue(planet.EntityId, out planetInfo))
            {
                Debug.Assert(false, "Could not get planet info!");
                return;
            }

            if (planetInfo.BotNumber >= MAX_BOTS_PER_PLANET) 
                return;

            Debug.Assert(animalSpawnInfo != null);
            double spawnDistMin = animalSpawnInfo.SpawnDistMin;
            double spawnDistMax = animalSpawnInfo.SpawnDistMax;
            Vector3D center = spawnInfo.Position;
            Vector3D planetGravityVec = MyGravityProviderSystem.CalculateNaturalGravityInPoint(center);
            //GR: if gravity is zero provide a random Vector to normalize
            if (planetGravityVec == Vector3D.Zero)
            {
                planetGravityVec = Vector3D.Up;
            }
            planetGravityVec.Normalize();
            Vector3D planetTangent = Vector3D.CalculatePerpendicularVector(planetGravityVec);
            Vector3D planetBitangent = Vector3D.Cross(planetGravityVec, planetTangent);
            planetTangent.Normalize();
            planetBitangent.Normalize();
            Vector3D spawnPos = MyUtils.GetRandomDiscPosition(ref center, spawnDistMin, spawnDistMax, ref planetTangent, ref planetBitangent);
            
            spawnPos = planet.GetClosestSurfacePointGlobal(ref spawnPos);
            Vector3D? spawnPosCorrected = MyEntities.FindFreePlace(spawnPos, 2.0f);
            if (spawnPosCorrected.HasValue)
                spawnPos = spawnPosCorrected.Value;

            planet.CorrectSpawnLocation(ref spawnPos, 2.0f);

            MyAgentDefinition botBehavior = GetAnimalDefinition(animalSpawnInfo) as MyAgentDefinition;
            if (botBehavior != null)
            {
                if (botBehavior.Id.SubtypeName == Wolf_SUBTYPE_ID && MySession.Static.EnableWolfs)
                {
                    MyAIComponent.Static.SpawnNewBot(botBehavior, spawnPos);
                }
                else if (botBehavior.Id.SubtypeName != Wolf_SUBTYPE_ID && MySession.Static.EnableSpiders)
                {
                    MyAIComponent.Static.SpawnNewBot(botBehavior, spawnPos);
                }
            }
        }
Пример #47
0
 public override void OnSpawnServer(SpawnInfo info)
 {
     base.OnSpawnServer(info);
     CurrentMagazine.containedBullets[0] = Projectile;
     CurrentMagazine.ServerSetAmmoRemains(1);
 }
Пример #48
0
    public static SpawnInfo ParseSpawn(string value)
    {
        SpawnInfo spawnInfo = new SpawnInfo();
        string[] datas = value.Split(SPLIT_DATA);

        spawnInfo.id = int.Parse(datas[0]);
        spawnInfo.right = (AxisType)int.Parse(datas[1]);
        spawnInfo.up = (AxisType)int.Parse(datas[2]);
        spawnInfo.forward = (AxisType)int.Parse(datas[3]);

        return spawnInfo;
    }
Пример #49
0
 public void OnSpawnServer(SpawnInfo info)
 {
     SyncCuffed(cuffed, this.cuffed);
 }
Пример #50
0
 public void Spawn(CubeItem cube, SpawnInfo spawnInfo)
 {
     SetCube(cube, spawnInfo.right, spawnInfo.up, spawnInfo.forward);
 }
Пример #51
0
 public override void OnSpawnServer(SpawnInfo info)
 {
     UpdateFiremode(currentFiremode, 0);
     base.OnSpawnServer(info);
 }
Пример #52
0
 public void OnSpawnServer(SpawnInfo info)
 {
     SyncState(spriteSync, initialState);
 }
Пример #53
0
 /// <summary>
 /// Spawns the entity with name <paramref name="entityName"/> at <paramref name="spawnInfo"/>
 /// </summary>
 /// <param name="entityName"></param>
 /// <param name="spawnInfo"></param>
 /// <returns></returns>
 public GameObject Spawn(string entityName, SpawnInfo spawnInfo)
 {
     return(Spawn(Globals.Instance.Entities[entityName], spawnInfo));
 }
Пример #54
0
    private static void Create()
    {
        if (null == s_MagicCube)
        {
            GameObject gameObject = new GameObject(typeof(MagicCube).Name);
            s_MagicCube = gameObject.AddComponent<MagicCube>();
        }

        s_MagicCube.Generate(s_Id, s_Step, s_Size, s_Space, 0);
        s_DestCube = s_MagicCube.destCube;

        List<CubeItem> cubeList = s_MagicCube[s_MagicCube.layer];
        CubeItem cube = cubeList[UnityEngine.Random.Range(0, cubeList.Count)];

        List<AxisType> axisTypes = new List<AxisType>(cube.itemDict.Keys);
        int index = UnityEngine.Random.Range(0, axisTypes.Count);
        AxisType upAxis = axisTypes[index];

        axisTypes = new List<AxisType>(Enum.GetValues(typeof(AxisType)) as AxisType[]);

        axisTypes.Remove(upAxis);
        axisTypes.Remove((AxisType)(-(int)upAxis));

        index = UnityEngine.Random.Range(0, axisTypes.Count);
        AxisType rightAxis = axisTypes[index];

        axisTypes.Remove(rightAxis);
        axisTypes.Remove((AxisType)(-(int)rightAxis));

        index = UnityEngine.Random.Range(0, axisTypes.Count);
        AxisType forwardAxis = axisTypes[index];

        s_SpawnInfo = new SpawnInfo();
        s_SpawnInfo.id = cube.id;
        s_SpawnInfo.right = rightAxis;
        s_SpawnInfo.up = upAxis;
        s_SpawnInfo.forward = forwardAxis;

        Selection.activeGameObject = s_MagicCube.gameObject;
    }
Пример #55
0
    private Vector2 spawnMod_y = new Vector2 (1.0f, 1.5f); // The min and max spawn modification on the y axis

    #endregion Fields

    #region Methods

    public void Enqueue(SpawnInfo objSpawnInfo)
    {
        globalSpawnQueue.Enqueue(objSpawnInfo);
    }