public IEnumerator RespawnCo2()
    {
        player2.GetComponent <Renderer>().enabled = false;
        yield return(new WaitForSeconds(respawnDelay));

        player2.enabled = true;
        player2.GetComponent <Renderer>().enabled           = true;
        player2.GetComponent <Rigidbody> ().velocity        = Vector3.zero;                     // Reset ball to zero velocity
        player2.GetComponent <Rigidbody> ().angularVelocity = Vector3.zero;                     // Reset ball to zero angular velocity


        player2.transform.position = p2SpawnPoint.transform.position;
    }
Beispiel #2
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Player"))
     {
         if (!player.GetComponent <PlayerParry>().IsParry)
         {
             player.StopByWater = true;
             Vector2 pos         = new Vector2(other.transform.position.x, col.bounds.max.y);
             var     salpicadura = Instantiate(gotas, pos, Quaternion.Euler(-90, 0f, 0f));
             Destroy(salpicadura, 0.5f);
             source.pitch = Random.Range(0.8f, 1.2f);
             source.Play();
             plAudio.walkSound.clip = soundSteps[0];
         }
     }
 }
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag("Player"))
     {
         player.gameObject.GetComponent <PlayerAttack>().haveSword = true;
         FindObjectOfType <NpcDialogue>().TriggerDialogue();
         source.Play();
         ScenesManager.scenesManager.SwordPicked = true;
         SaveSystem.SavePlayerData(player.GetComponent <PlayerController2>(), player.GetComponentInChildren <Inventory2>(), player.GetComponent <PlayerAttack>());
         GetComponent <Collider2D>().enabled = false;
         Destroy(gameObject.transform.GetChild(0).gameObject);
         StartCoroutine(DeviceImages());
     }
 }
Beispiel #4
0
    IEnumerator TP()
    {
        yield return(new WaitForSeconds(0.1f));

        player.StartTP = true;
        ScenesManager.scenesManager.ApearsOnFountain = true;
        yield return(new WaitForSeconds(1f));

        GameObject.FindObjectOfType <LevelDoor>().Anim.SetTrigger("FadeIn");
        yield return(new WaitForSeconds(1.2f));

        inventory.nTP--;
        SaveSystem.SavePlayerData(player, inventory, player.GetComponent <PlayerAttack>());
        SceneManager.LoadScene(sceneToLoad);
    }
Beispiel #5
0
    public IEnumerator RespawnPlayerCo()
    {
        Instantiate(DeathParticle, player.transform.position, player.transform.rotation);
        player.enabled = false;
        player.GetComponent <Renderer>().enabled = false;
        gravityStore = player.GetComponent <Rigidbody2D>().gravityScale;
        player.GetComponent <Rigidbody2D>().gravityScale = 0f;
        player.GetComponent <Rigidbody2D>().velocity     = Vector2.zero;
        Debug.Log("Player Respawn");
        yield return(new WaitForSeconds(respawnDelay));

        player.GetComponent <Rigidbody2D>().gravityScale = gravityStore;
        player.transform.position = currentCheckpoint.transform.position;
        player.enabled            = true;
        player.GetComponent <Renderer>().enabled = true;
        Instantiate(RespawnParticle, player.transform.position, player.transform.rotation);
    }
    // Check the preconditions for the action to be realised.
    public override bool checkProceduralPrecondition(GameObject agent)
    {
        // Find the nearest player to attack
        PlayerController2[] players       = GameObject.FindObjectsOfType <PlayerController2>();
        PlayerController2   closestPlayer = null;
        float closestDistance             = 0;

        foreach (PlayerController2 player in players)
        {
            if (closestPlayer == null)
            {
                closestPlayer   = player;
                closestDistance = (player.transform.position - agent.transform.position).magnitude;
            }
            else
            {
                float distance = (player.transform.position - agent.transform.position).magnitude;
                if (distance < closestDistance)
                {
                    closestPlayer   = player;
                    closestDistance = distance;
                }
            }
        }

        if (closestPlayer == null)
        {
            return(false);
        }

        targetPlayer       = closestPlayer;
        targetPlayerHealth = targetPlayer.GetComponent <PlayerHealth>();
        target             = targetPlayer.gameObject;
        cost = closestDistance * (((ZombieAgent.TankNear)GetComponent <IGoap>().getWorldState()["isTankNearby"]).isNear ? 3 : 1);
        return(true);
    }