Exemplo n.º 1
0
 void Activable(Transform T)
 {
     MessageCanvas.gameObject.SetActive(true);
     MessageCanvas.GetComponent <UnityEngine.UI.Text>().text = activable.Message.text;
     if (Input.GetKeyUp(KeyCode.E))
     {
         activable.Activate();
     }
 }
Exemplo n.º 2
0
    // Ball collision with other objects
    private void OnTriggerEnter(Collider other)
    {
        //Check for a collision with an enemy
        Enemy potentialEnemy = other.GetComponent <Enemy>();

        if (potentialEnemy != null && direction != Vector3.zero && triggerEnabled)
        {
            Enemy enemy = potentialEnemy;
            enemy.AddDamage(Mathf.RoundToInt(GameManager.i.ballManager.GetDamages() * damageModifier));
            enemy.Slow(0.2f, 1);
            GameManager.i.momentumManager.IncrementMomentum(GameManager.i.momentumManager.momentumGainedPerEnemyHit);
        }

        //Check for a collision with a player (To pick the ball when it's on the ground)
        PlayerController potentialPlayer = other.GetComponent <PlayerController>();

        if (potentialPlayer != null && canBePicked)
        {
            potentialPlayer.TakeBall(this, 0);
        }

        //Check for a collision with a player (Ball belong to an enemy and is "spiky")
        if (potentialPlayer != null && state == BallMoveState.Spiky)
        {
            potentialPlayer.Push(direction.normalized, 5);
            potentialPlayer.AddDamage(20);
        }

        //Check for a destructible object
        // TODO


        //Check for an activable Object
        ActivableObject potentialActObject = other.GetComponent <ActivableObject>();

        if (potentialActObject != null)
        {
            potentialActObject.Activate();
            //Diminish the Momentum of the value
        }
    }