Exemple #1
0
 private void Reset()
 {
     if (stats == null)
     {
         stats = ScriptableObject.CreateInstance("SPlayerStats") as SPlayerStats;
     }
     stats.hp              = statsDefault.hp;
     stats.gold            = statsDefault.gold;
     stats.position        = statsDefault.position;
     stats.facingDirection = statsDefault.facingDirection;
     playerStatsChangeEvent.Raise();
 }
Exemple #2
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Player"))
     {
         Destroy(colliderComponent);
         roomExitEvent.Raise();
     }
 }
Exemple #3
0
 private void LateUpdate()
 {
     speed = Vector3.Magnitude(transform.position - previousPosition) / Time.deltaTime;
     if (speed > 0)
     {
         playerMove.Raise();
     }
 }
Exemple #4
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        SEvent myScript = (SEvent)target;

        if (GUILayout.Button("Raise Event"))
        {
            myScript.Raise();
        }
    }
Exemple #5
0
    public void Hit(float damageReceived)
    {
        stats.hp -= damageReceived;

        GameObjectPool.instance.Spawn("Blood", transform.position + Vector3.up * 8f, transform.rotation, Vector3.one);
        if (stats.hp <= 0)
        {
            stats.hp = 0f;
            playerDeath.Raise();
        }
        else
        {
            //deve entrare nello stato di GRAZIA
        }
        playerStatsChangeEvent.Raise();
    }
Exemple #6
0
 void Update()
 {
     if (Input.GetButtonDown("Start"))
     {
         Debug.Log("Start Game");
         startButtonEvent.Raise();
     }
     if (Input.GetButtonDown("Pause"))
     {
         pauseButtonEvent.Raise();
         Debug.Log("Pause Game");
     }
     if (Input.GetButtonDown("Quit"))
     {
         Application.Quit();
     }
 }
Exemple #7
0
 public void Die()
 {
     state = MonsterState.dead;
     monsterKilled.Raise();
     Destroy(gameObject);
 }
Exemple #8
0
 public void FadedOut()
 {
     fadedOut.Raise();
 }
Exemple #9
0
 public void FadedIn()
 {
     fadedIn.Raise();
 }
Exemple #10
0
    public void InitRoom(GameObject roomPrefab, SMonsterSpawnConfiguration monstersToSpawn)
    {
        //SaveGameManager.instance.SaveGame(playerStats.roomNumber, playerStats.hp, playerStats.gold);
        int i, j;

        //GameObject room =
        room = Instantiate(roomPrefab);

        surface.BuildNavMesh();

        players = new List <Player>(GameObject.FindObjectsOfType <Player>());
        foreach (Player p in players)
        {
            p.EnableAgent(false);
        }

        spawnMonster = new List <GameObject>(GameObject.FindGameObjectsWithTag("Spawner"));
        j            = 0;
        foreach (SMonsterSpawnConfiguration.Spawner s in monstersToSpawn.monsters)
        {
            for (i = 0; i < s.numberToSpawn; i++)
            {
                //Debug.Log("Instanzio nuovo mostro.");
                GameObject newMonster = Instantiate(s.monsterToSpawn, spawnMonster[j % spawnMonster.Count].transform.position, spawnMonster[j % spawnMonster.Count].transform.rotation);
                newMonster.transform.rotation = spawnMonster[j % spawnMonster.Count].transform.rotation;
                monsters.Add(newMonster.GetComponent <Monster>());
                monstersAlive++;
                //Debug.Log("Mostro " + newMonster.name + " " + monstersAlive + " " + newMonster.transform.position + " " + monsters.Count);
                j++;
            }
        }

        doors = new List <Door>(GameObject.FindObjectsOfType <Door>());

        spawnPlayer = new List <GameObject>(GameObject.FindGameObjectsWithTag("SpawnerPlayer"));

        for (i = 0; i < spawnPlayer.Count; i++)
        {
            RoomExit newSpawnPoint = Instantiate(playerSpawnExitPrefab, spawnPlayer[i].transform.position, spawnPlayer[i].transform.rotation);
            exits.Add(newSpawnPoint);
            newSpawnPoint.EnableExit(false);
            spawnPlayer[i] = newSpawnPoint.gameObject;
        }

        i = 0;
        foreach (Player p in players)
        {
            p.transform.position = spawnPlayer[i % spawnPlayer.Count].transform.position;
            p.transform.rotation = spawnPlayer[i % spawnPlayer.Count].transform.rotation;
            //elimino la  possibilita' di uscire da qua
            spawnPlayer[i % spawnPlayer.Count].GetComponent <RoomExit>().CloseExit();
            //print(p.transform.position + " " + spawnPlayer[i % spawnPlayer.Length].transform.position);
            float minDistance = 80000f;
            int   closestDoor = 0;
            for (j = 0; j < doors.Count; j++)
            {
                if (Vector3.Distance(p.transform.position, doors[j].transform.position) < minDistance)
                {
                    minDistance = Vector3.Distance(p.transform.position, doors[j].transform.position);
                    closestDoor = j;
                }
            }
            doors[closestDoor].Block();
            i++;
            p.EnableAgent(true);
        }

        roomLoaded.Raise();
        //Debug.Log("Number of monsters: " + monsters.Count + " " + GameObject.FindGameObjectsWithTag("Monster").Length);
    }
Exemple #11
0
 public void ExitRoom()
 {
     Debug.Log("Player exits room");
     destroyRoom.Raise();
     //ClearRoom();
 }