Пример #1
0
    public static BasePlayer.SpawnPoint FindSpawnPoint()
    {
        if (Object.op_Inequality((Object)SingletonComponent <SpawnHandler> .Instance, (Object)null))
        {
            BasePlayer.SpawnPoint spawnPoint = SpawnHandler.GetSpawnPoint();
            if (spawnPoint != null)
            {
                return(spawnPoint);
            }
        }
        BasePlayer.SpawnPoint spawnPoint1        = new BasePlayer.SpawnPoint();
        GameObject[]          gameObjectsWithTag = GameObject.FindGameObjectsWithTag("spawnpoint");
        if (gameObjectsWithTag.Length != 0)
        {
            GameObject gameObject = gameObjectsWithTag[Random.Range(0, gameObjectsWithTag.Length)];
            spawnPoint1.pos = gameObject.get_transform().get_position();
            spawnPoint1.rot = gameObject.get_transform().get_rotation();
        }
        else
        {
            Debug.Log((object)"Couldn't find an appropriate spawnpoint for the player - so spawning at camera");
            if (Object.op_Inequality((Object)MainCamera.mainCamera, (Object)null))
            {
                spawnPoint1.pos = ((Component)MainCamera.mainCamera).get_transform().get_position();
                spawnPoint1.rot = ((Component)MainCamera.mainCamera).get_transform().get_rotation();
            }
        }
        RaycastHit raycastHit;

        if (Physics.Raycast(new Ray(spawnPoint1.pos, Vector3.get_down()), ref raycastHit, 32f, 1537286401))
        {
            spawnPoint1.pos = ((RaycastHit) ref raycastHit).get_point();
        }
        return(spawnPoint1);
    }
 private void OnServerAddPlayerInternal(NetworkConnection conn)
 {
     if (playerPrefab == null)
     {
         if (!LogFilter.Debug)
         {
             return;
         }
         Logger.LogError("The PlayerPrefab is empty on the NetworkManager. Please setup a PlayerPrefab object.", Category.Connections);
     }
     else if (playerPrefab.GetComponent <NetworkIdentity>() == null)
     {
         if (!LogFilter.Debug)
         {
             return;
         }
         Logger.LogError("The PlayerPrefab does not have a NetworkIdentity. Please add a NetworkIdentity to the player prefab.", Category.Connections);
     }
     // else if (playerControllerId < conn.playerControllers.Count && conn.playerControllers[playerControllerId].IsValid &&
     //  conn.playerControllers[playerControllerId].gameObject != null)
     // {
     //  if (!LogFilter.Debug)  FIXME!! - need a way to determine if player has already spawned before this round
     //  {
     //      return;
     //  }
     //  Logger.LogError("There is already a player at that playerControllerId for this connections.", Category.Connections);
     // }
     else
     {
         SpawnHandler.SpawnViewer(conn);
     }
 }
Пример #3
0
        private void StartGameEventHandler(object sender, EventArgs e)
        {
            // initialization
            _objects            = new List <AnimatedObject>();
            _enemies            = new List <AnimatedObject>();
            _objectsToBeDeleted = new List <AnimatedObject>();
            _spawner            = new SpawnHandler(this.Canvas.Width, this.Canvas.Height, 4);
            this.Player         = _spawner.SpawnPlayer();
            _inputHandler       = new InputHandler(this.Canvas, this.Player, this._spawner);

            _timer.Tick                    += this.AnimateObjects;
            _spawner.ObjectsSpawned        += this.AddObjectEventHandler;
            _inputHandler.EscapeKeyPressed += this.EndGame;

            // Setup for Gameplay
            _objects.Add(this.Player);
            this.CurrentQuestion = _spawner.GetQuestion();
            // First Spawn after this amount of seconds
            _nextSpawn           = DateTime.Now.AddSeconds(spawnInterval);
            this.CurrentWave     = 0;
            _spawnAllowed        = true;
            this.Points          = 1;
            this.QuestionCounter = 1;
            this.Message         = "Shoot the wrong answers!";

            _timer.Interval = TimeSpan.FromSeconds(timerInterval);
            _timer.Start();
        }
Пример #4
0
    public static bool GetSpawnPoint(BasePlayer.SpawnPoint spawnPoint, float searchHeight)
    {
        SpawnHandler instance = SingletonComponent <SpawnHandler> .Instance;

        if (TerrainMeta.HeightMap == null || instance == null)
        {
            return(false);
        }
        LayerMask placementMask        = instance.PlacementMask;
        LayerMask placementCheckMask   = instance.PlacementCheckMask;
        float     placementCheckHeight = instance.PlacementCheckHeight;
        LayerMask radiusCheckMask      = instance.RadiusCheckMask;
        float     radiusCheckDistance  = instance.RadiusCheckDistance;

        for (int i = 0; i < 10; i++)
        {
            Vector3    vector = FindSpawnPoint(searchHeight);
            RaycastHit hitInfo;
            if ((int)placementCheckMask != 0 && Physics.Raycast(vector + Vector3.up * placementCheckHeight, Vector3.down, out hitInfo, placementCheckHeight, placementCheckMask))
            {
                if (((1 << hitInfo.transform.gameObject.layer) & (int)placementMask) == 0)
                {
                    continue;
                }
                vector.y = hitInfo.point.y;
            }
            if ((int)radiusCheckMask == 0 || !Physics.CheckSphere(vector, radiusCheckDistance, radiusCheckMask))
            {
                spawnPoint.pos = vector;
                spawnPoint.rot = Quaternion.Euler(0f, UnityEngine.Random.Range(0f, 360f), 0f);
                return(true);
            }
        }
        return(false);
    }
Пример #5
0
        public static void scalars(ConsoleSystem.Arg args)
        {
            TextTable textTable = new TextTable();

            textTable.AddColumn("Type");
            textTable.AddColumn("Value");
            textTable.AddRow(new string[2]
            {
                "Player Fraction",
                SpawnHandler.PlayerFraction().ToString()
            });
            textTable.AddRow(new string[2]
            {
                "Player Excess",
                SpawnHandler.PlayerExcess().ToString()
            });
            textTable.AddRow(new string[2]
            {
                "Population Rate",
                SpawnHandler.PlayerLerp(Spawn.min_rate, Spawn.max_rate).ToString()
            });
            textTable.AddRow(new string[2]
            {
                "Population Density",
                SpawnHandler.PlayerLerp(Spawn.min_density, Spawn.max_density).ToString()
            });
            textTable.AddRow(new string[2]
            {
                "Group Rate",
                SpawnHandler.PlayerScale(Spawn.player_scale).ToString()
            });
            args.ReplyWith(((object)textTable).ToString());
        }
Пример #6
0
    public static BasePlayer.SpawnPoint FindSpawnPoint()
    {
        RaycastHit raycastHit;

        if (SingletonComponent <SpawnHandler> .Instance != null)
        {
            BasePlayer.SpawnPoint spawnPoint = SpawnHandler.GetSpawnPoint();
            if (spawnPoint != null)
            {
                return(spawnPoint);
            }
        }
        BasePlayer.SpawnPoint spawnPoint1     = new BasePlayer.SpawnPoint();
        GameObject[]          gameObjectArray = GameObject.FindGameObjectsWithTag("spawnpoint");
        if (gameObjectArray.Length == 0)
        {
            UnityEngine.Debug.Log("Couldn't find an appropriate spawnpoint for the player - so spawning at camera");
            if (MainCamera.mainCamera != null)
            {
                spawnPoint1.pos = MainCamera.mainCamera.transform.position;
                spawnPoint1.rot = MainCamera.mainCamera.transform.rotation;
            }
        }
        else
        {
            GameObject gameObject = gameObjectArray[UnityEngine.Random.Range(0, (int)gameObjectArray.Length)];
            spawnPoint1.pos = gameObject.transform.position;
            spawnPoint1.rot = gameObject.transform.rotation;
        }
        if (UnityEngine.Physics.Raycast(new Ray(spawnPoint1.pos, UnityEngine.Vector3.down), out raycastHit, 32f, 1537286401))
        {
            spawnPoint1.pos = raycastHit.point;
        }
        return(spawnPoint1);
    }
Пример #7
0
    public void ClonePlayer(GameObject spawnPoint, CharacterSettings characterSettings)
    {
        GameObject oldBody    = GetCurrentMob();
        var        connection = oldBody.GetComponent <NetworkIdentity>().connectionToClient;

        SpawnHandler.ClonePlayer(connection, jobType, characterSettings, oldBody, spawnPoint);
    }
Пример #8
0
        void RandomSpawns()
        {
            spawns.Clear();
            int failed = 0;

            while (failed < 1000 && spawns.Count < spawnsCount)
            {
                BasePlayer.SpawnPoint spawnPoint = SpawnHandler.GetSpawnPoint();

                if (spawnPoint == null)
                {
                    failed++;
                    continue;
                }
                if (!IsValidSpawn(spawnPoint.pos))
                {
                    failed++;
                    continue;
                }
                spawns.Add(spawnPoint.pos);
            }
            if (failed >= 1000)
            {
                Puts("FAILED > 1000");
            }
            Puts("CREATED " + spawns.Count.ToString());
            spawnsFile.WriteObject(JsonConvert.SerializeObject(spawns, converter));
        }
 private void OnServerAddPlayerInternal(NetworkConnection conn, short playerControllerId)
 {
     if (playerPrefab == null)
     {
         if (!LogFilter.logError)
         {
             return;
         }
         Logger.LogError("The PlayerPrefab is empty on the NetworkManager. Please setup a PlayerPrefab object.", Category.Connections);
     }
     else if (playerPrefab.GetComponent <NetworkIdentity>() == null)
     {
         if (!LogFilter.logError)
         {
             return;
         }
         Logger.LogError("The PlayerPrefab does not have a NetworkIdentity. Please add a NetworkIdentity to the player prefab.", Category.Connections);
     }
     else if (playerControllerId < conn.playerControllers.Count && conn.playerControllers[playerControllerId].IsValid &&
              conn.playerControllers[playerControllerId].gameObject != null)
     {
         if (!LogFilter.logError)
         {
             return;
         }
         Logger.LogError("There is already a player at that playerControllerId for this connections.", Category.Connections);
     }
     else
     {
         SpawnHandler.SpawnPlayer(conn, playerControllerId);
     }
 }
Пример #10
0
        public static States StartGame(GameHandler gameHandle)
        {
            if (gameHandle == null)
            {
                gameHandler = GameHandler.GenerateHandler();
                Enemies     = gameHandler.Enemies;
                playerInformationHandler.VerifyUnlockedPlayer();
                Reload();
                if (playerInformationHandler.UnlockedCompanion)
                {
                    companion = new Companion("Player/companion", player.X + 30, player.Y + 30, 200, 200, playerInformationHandler.SelectedBullet, 5, player);
                }
            }
            else
            {
                gameHandler = gameHandle;
                Enemies     = gameHandler.Enemies;
                player      = gameHandler.Player;
                companion   = gameHandler.Companion;
            }
            spawnHandler = new SpawnHandler(gameHandler);

            Enemies.CollectionChanged += EnemiesChanged;
            return(States.Run);
        }
Пример #11
0
        public static void scalars(ConsoleSystem.Arg args)
        {
            TextTable textTable = new TextTable();

            textTable.AddColumn("Type");
            textTable.AddColumn("Value");
            string[] str    = new string[] { "Player Fraction", null };
            float    single = SpawnHandler.PlayerFraction();

            str[1] = single.ToString();
            textTable.AddRow(str);
            string[] strArrays = new string[] { "Player Excess", null };
            single       = SpawnHandler.PlayerExcess();
            strArrays[1] = single.ToString();
            textTable.AddRow(strArrays);
            string[] str1 = new string[] { "Population Rate", null };
            single  = SpawnHandler.PlayerLerp(Spawn.min_rate, Spawn.max_rate);
            str1[1] = single.ToString();
            textTable.AddRow(str1);
            string[] strArrays1 = new string[] { "Population Density", null };
            single        = SpawnHandler.PlayerLerp(Spawn.min_density, Spawn.max_density);
            strArrays1[1] = single.ToString();
            textTable.AddRow(strArrays1);
            string[] str2 = new string[] { "Group Rate", null };
            single  = SpawnHandler.PlayerScale(Spawn.player_scale);
            str2[1] = single.ToString();
            textTable.AddRow(str2);
            args.ReplyWith(textTable.ToString());
        }
Пример #12
0
 public void CmdSpawnPlayerGhost()
 {
     if (GetComponent <LivingHealthBehaviour>().IsDead)
     {
         var newGhost = SpawnHandler.SpawnPlayerGhost(connectionToClient, playerControllerId, gameObject, playerScript.characterSettings);
         playerScript.mind.Ghosting(newGhost);
     }
 }
Пример #13
0
 public void CmdRespawnPlayer()
 {
     if (GameManager.Instance.RespawnCurrentlyAllowed)
     {
         SpawnHandler.RespawnPlayer(connectionToClient, playerControllerId, playerScript.mind.jobType, playerScript.characterSettings, gameObject);
         RpcAfterRespawn();
     }
 }
 // Use this for initialization
 void Start()
 {
     handler     = GameObject.FindGameObjectWithTag("GameController").GetComponent <SpawnHandler>();
     target      = GameObject.FindGameObjectWithTag("Edificio").transform;
     agent       = GetComponent <NavMeshAgent>();
     destination = target.position;
     agent.SetDestination(destination);
 }
Пример #15
0
 public float GetMaximumSpawnDensity()
 {
     if (!this.ScaleWithServerPopulation)
     {
         return(2f * this.TargetDensity * Spawn.max_density * 1E-06f);
     }
     return(2f * this.TargetDensity * SpawnHandler.PlayerLerp(Spawn.min_density, Spawn.max_density) * 1E-06f);
 }
Пример #16
0
    private IEnumerator InitiateRespawn(int timeout)
    {
        //Debug.LogFormat("{0}: Initiated respawn in {1}s", gameObject.name, timeout);
        yield return(new WaitForSeconds(timeout));

        SpawnHandler.RespawnPlayer(connectionToClient, playerControllerId, playerScript.JobType);
        RpcAfterRespawn();
    }
Пример #17
0
 // Use this for initialization
 void Start()
 {
     if (!Debug.isDebugBuild)
     {
         gameObject.SetActive(false);
     }
     spawn = GameObject.FindGameObjectWithTag("Spawner").GetComponent <SpawnHandler>();
 }
Пример #18
0
 public float GetCurrentSpawnRate()
 {
     if (this.ScaleWithServerPopulation)
     {
         return(this.SpawnRate * SpawnHandler.PlayerLerp(Spawn.min_rate, Spawn.max_rate));
     }
     return(this.SpawnRate * Spawn.max_rate);
 }
Пример #19
0
 public float GetMaximumSpawnDensity()
 {
     if (this.ScaleWithServerPopulation)
     {
         return((float)(2.0 * (double)this.TargetDensity * (double)SpawnHandler.PlayerLerp(Spawn.min_density, Spawn.max_density) * 9.99999997475243E-07));
     }
     return((float)(2.0 * (double)this.TargetDensity * (double)Spawn.max_density * 9.99999997475243E-07));
 }
Пример #20
0
 public bool HasSpaceToSpawn()
 {
     if (useCustomBoundsCheckMask)
     {
         return(SpawnHandler.CheckBounds(entityPrefab.Get(), base.transform.position, base.transform.rotation, Vector3.one, customBoundsCheckMask));
     }
     return(SingletonComponent <SpawnHandler> .Instance.CheckBounds(entityPrefab.Get(), base.transform.position, base.transform.rotation, Vector3.one));
 }
Пример #21
0
 void OnTriggerEnter(Collider other)
 {
     if (start && other.gameObject.tag.Equals("Player"))
     {
         SpawnHandler diffIncrease = GameObject.Find("DungeonCreator").GetComponent <SpawnHandler>();
         diffIncrease.incDiff();
         Destroy(gameObject);
     }
 }
Пример #22
0
        public override void ProcessMessage(ConnectBase conn, ByteBuffer data)
        {
            int moduleId = data.readByte();

            switch (moduleId)
            {
            case BATTLE_START:
            {
                BattleManager.GetInst().m_BattleScene.OnBattleStart();
                break;
            }

            case BATTLE_COIN:
            {
                BattleManager.GetInst().m_BattleScene.Coin = data.readInt();
                break;
            }

            case BATTLE_CUR_SPAWN:
            {
                SpawnHandler.GetInst().SetSpawnInfo(data.readInt());
                break;
            }

            case BATTLE_CUR_WAVE:
            {
                SpawnHandler.GetInst().CurWave = data.readInt();
                SpawnHandler.GetInst().ReleaseCurWave();
                break;
            }

            case BATTLE_HIGHEST_SPAWN:
            {
                int highestLv = data.readInt();
                //
                break;
            }

            case BATTLE_TASK:
            {
                int taskId = data.readInt();
                BattleTaskFinishPanel.GetInst().Show(taskId);
                break;
            }

            case BATTLE_HERO:
            {
                BattleManager.GetInst().AddHero(data.readInt(), data.readInt(), data.readByte());
                break;
            }

            case BATTLE_HERO_LEVEL:
            {
                break;
            }
            }
        }
Пример #23
0
    public void CmdEnterBody()
    {
        playerScript.mind.StopGhosting();
        var body = playerScript.mind.body.gameObject;

        SpawnHandler.TransferPlayer(connectionToClient, body, gameObject, EVENT.PlayerSpawned, null);
        body.GetComponent <PlayerScript>().playerNetworkActions.ReenterBodyUpdates(body);
        RpcAfterRespawn();
    }
    // Use this for initialization
    void Start()
    {
        handler = GameObject.FindGameObjectWithTag("GameController").GetComponent <SpawnHandler>();

        centerMap   = GameObject.Find("Plano").transform.position;
        sizeMap     = GameObject.Find("Plano").transform.localScale;
        agent       = GetComponent <NavMeshAgent> ();
        destination = GetRandomPos();
        agent.SetDestination(destination);
    }
Пример #25
0
 // Awake is called before Start()
 void Awake()
 {
     // set the reference to the current instance
     if (Instance == null)
     {
         Instance = this;
     }
     else if (Instance != this)
     {
         Destroy(gameObject);
     }
 }
Пример #26
0
 public void CloseMenu()
 {
     foreach (Controller controller in SpawnHandler.GetAllControllers())
     {
         controller.PauseController(false);
     }
     terrain.GetComponent <TerrainFader>().PartiallyFade(1f);
     objectives.GetComponent <ObjectiveHandler>().PartiallyFade(1f);
     helpText.color = new Color(helpText.color.r, helpText.color.g, helpText.color.b, 1f);
     active.SetActive(false);
     cooldown = 20;
     inMenu   = false;
 }
Пример #27
0
 void ShowMenu()
 {
     foreach (Controller controller in SpawnHandler.GetAllControllers())
     {
         controller.PauseController(true);
     }
     terrain.GetComponent <TerrainFader>().PartiallyFade(0.5f);
     objectives.GetComponent <ObjectiveHandler>().PartiallyFade(0.5f);
     helpText.color = new Color(helpText.color.r, helpText.color.g, helpText.color.b, 0.5f);
     active.SetActive(true);
     cooldown = 20;
     inMenu   = true;
 }
Пример #28
0
        public static void scalars(Arg args)
        {
            TextTable textTable = new TextTable();

            textTable.AddColumn("Type");
            textTable.AddColumn("Value");
            textTable.AddRow("Player Fraction", SpawnHandler.PlayerFraction().ToString());
            textTable.AddRow("Player Excess", SpawnHandler.PlayerExcess().ToString());
            textTable.AddRow("Population Rate", SpawnHandler.PlayerLerp(min_rate, max_rate).ToString());
            textTable.AddRow("Population Density", SpawnHandler.PlayerLerp(min_density, max_density).ToString());
            textTable.AddRow("Group Rate", SpawnHandler.PlayerScale(player_scale).ToString());
            args.ReplyWith(textTable.ToString());
        }
Пример #29
0
 // Update is called once per frame
 void Update()
 {
     if (smallCubeObjectiveMet && bigCubeObjectiveMet)
     {
         foreach (IFadeable fader in levelGameObject.GetComponentsInChildren(typeof(IFadeable)))
         {
             StartCoroutine(fader.FadeOut());
         }
         foreach (Controller controller in SpawnHandler.GetAllControllers())
         {
             StartCoroutine(controller.FadeOut());
         }
         StartCoroutine(LoadNextLevel());
     }
 }
Пример #30
0
    private void EnterRoom(RoomClass.ExitClass.TargetClass target, Vector3 deltaVector)
    {
        enemies.ForEach(x => { if (x != null && x.GameObject)
                               {
                                   Destroy(x.GameObject);
                               }
                        });
        enemies.Clear();

        ShowRoom(Rooms.Find(x => x.Id == target.RoomId));
        Player.transform.position = SpawnHandler.GetSpawnPoint(target.ExitId) + deltaVector;
        CollectedJewelSprites.ForEach(x => x.GetComponent <Rigidbody2D>().position = Player.transform.position);

        SpawnEnemies();
    }
Пример #31
0
	// Use this for initialization
	void Start () {
		gm = GameObject.Find ("GameManager").GetComponent<GameManager>();
		sh = gm.spawnHandler.GetComponent<SpawnHandler>();
		gameCamera = GameObject.Find ("MainCamera").GetComponent<CameraController>();
	}
Пример #32
0
    public void StartGame()
    {
        //Beginning game setup
        GameActive = true;

        CreatePlayer(true, 0);

        //Wait();
        //start spawning
        //Spawn();
        spawnHandler = new SpawnHandler();
    }
Пример #33
0
 public void Start()
 {
     handler = GameObject.FindGameObjectWithTag("SpawnController").GetComponent<SpawnHandler>();
     spriteRenderer = GetComponent<SpriteRenderer>();
     spriteRenderer.color = new Color(spriteRenderer.color.r, spriteRenderer.color.g, spriteRenderer.color.b, 0.0f);
 }