Beispiel #1
0
    void die_player()
    {
        player.gameObject.GetComponent <FirstPersonController>().GetEntity().GetState <IPlayerState>().deaths++;
        WeaponControl weapons = EquipmentUI.GetComponent <WeaponControl>();

        weapons.openMenu();

        var evnt = PlayerVisibilityChanged.Create(Bolt.GlobalTargets.Others);

        evnt.Player  = player.GetComponent <FirstPersonController>().GetEntity();
        evnt.Visible = false;
        evnt.Send();
        player.SetActive(false);
    }
Beispiel #2
0
    /// <summary>
    /// Unity lifecycle update method. Actviates the player's GameObject. Updates chunks based on the player's position.
    /// </summary>
    ///
    public void deactivate_Player()
    {
        FirstPersonController a = player.GetComponent <FirstPersonController>();

        a.freeMouse();

        var evnt = PlayerVisibilityChanged.Create(Bolt.GlobalTargets.Others);

        evnt.Player  = player.GetComponent <FirstPersonController>().GetEntity();
        evnt.Visible = false;
        evnt.Send();

        player.SetActive(false);
    }
Beispiel #3
0
    public void spawnPlayer()
    {
        var evnt = PlayerVisibilityChanged.Create(Bolt.GlobalTargets.Others);

        evnt.Player  = player.GetComponent <FirstPersonController>().GetEntity();
        evnt.Visible = true;
        evnt.Send();

        player.SetActive(true);
        player.GetComponent <FirstPersonController>().bindMouse();
        activate_ALIVE_UI();
        ArmorAndWeapons armor   = ArmorUI.GetComponent <ArmorAndWeapons>();
        Stamina         stamina = StaminaUI.GetComponent <Stamina>();
        Hearts          health  = HealthUI.GetComponent <Hearts>();
        WeaponControl   weapons = EquipmentUI.GetComponent <WeaponControl>();

        armor.resetArmor();
        stamina.resetStamina();
        health.resetHealth();
        weapons.onSpawn();
        player.transform.position = randomSpawnpoint();
    }
Beispiel #4
0
    public override void OnEvent(PlayerVisibilityChanged evnt)
    {
        var script = evnt.Player.gameObject.GetComponent <PlayerStartScript>();

        script.TogglePlayerVisibility(evnt.Visible);
    }
Beispiel #5
0
    /// <summary>
    /// Unity lifecycle start method. Initializes the world and its first chunk and triggers the building of further chunks.
    /// Player is disabled during Start() to avoid him falling through the floor. Chunks are built using coroutines.
    /// </summary>
    void Start()
    {
        /*
         *      Vector3 ppos = player.transform.position;
         *      player.transform.position = new Vector3(ppos.x,
         *                                                                              Noise.GenerateHeight(ppos.x,ppos.z) + 2,
         *                                                                              ppos.z);
         *      lastbuildPos = player.transform.position;
         *      player.SetActive(false);
         */
        firstbuild = true;
        chunks     = new ConcurrentDictionary <string, Chunk>();

        /*
         * this.transform.position = Vector3.zero;
         * this.transform.rotation = Quaternion.identity;
         */

        spawnPosX = worldSize * chunkSize / 2;
        spawnPosZ = worldSize * chunkSize / 2;


        Vector3 ppos = player.transform.position;

        player.transform.position = randomSpawnpoint();

        /*
         * player.transform.position = new Vector3(spawnPosX,
         *                                                                      Noise.GenerateHeight(spawnPosX,spawnPosZ) + 2,
         *                                                                      spawnPosZ);
         *
         */
        var evnt = PlayerVisibilityChanged.Create(Bolt.GlobalTargets.Others);

        evnt.Player  = player.GetComponent <FirstPersonController>().GetEntity();
        evnt.Visible = false;
        evnt.Send();

        player.SetActive(false);

        BuildChunkAt((int)(player.transform.position.x / chunkSize),
                     (int)(player.transform.position.y / chunkSize),
                     (int)(player.transform.position.z / chunkSize));
        DrawChunks();

        for (int y = 0; y < columnHeight; y++)
        {
            BuildChunkAt((int)player.transform.position.x / chunkSize, y, (int)player.transform.position.z / chunkSize);
        }
        DrawChunks();

        queue = new CoroutineQueue(maxCoroutines, StartCoroutine);

        for (int x = 0; x < worldSize; x++)
        {
            for (int z = 0; z < worldSize; z++)
            {
                for (int y = 0; y < columnHeight; y++)
                {
                    BuildChunkAt(x, y, z);
                }
            }
        }


        // Draw starting chunk
        queue.Run(DrawChunks());



        /*
         * // Create further chunks
         * queue.Run(BuildRecursiveWorld((int)(player.transform.position.x/chunkSize),
         *                                                                      (int)(player.transform.position.y/chunkSize),
         *                                                                      (int)(player.transform.position.z/chunkSize),radius,radius));
         */
    }