Exemplo n.º 1
0
    void OnTriggerEnter(Collider collision)
    {
        /* does the collided object have a Player component */
        if (collision.gameObject.GetComponentInParent <MP_PlayerController>() != null)
        {
            Debug.Log("projectile hit");
            // tell target to take damage
            MP_PlayerController target = collision.gameObject.GetComponentInParent <MP_PlayerController>();
            target.health -= power;
            CmdPlayerSetHealth(target.player);
            // kill projectile
            Destroy(gameObject);
        }

        // did it collide with another spell/shield
        if (collision.gameObject.GetComponent <MP_Projectile>() != null)
        {
            power = power - collision.gameObject.GetComponent <MP_Projectile>().getPower();
            if (power <= 0)
            {
                // kill projectile
                Destroy(gameObject);
            }
        }
    }
Exemplo n.º 2
0
 public void SetGazedAt(bool gazedAt)
 {
     if (GameObject.FindWithTag("Player") != null)
     {
         GameObject localPlayer = GameObject.FindGameObjectWithTag("Player");
         if (localPlayer.GetComponent <MP_PlayerController>() != null)
         {
             MP_PlayerController controller = localPlayer.GetComponent <MP_PlayerController>();
             if (controller.player != null)
             {
                 MP_Player mainPlayer = controller.player;
                 if (mainPlayer.getSpellIndex() == 0 ||
                     (gazedAt == false &&
                      localPlayer.GetComponent <MP_PlayerController>().player.getSpellIndex() != 0))
                 {
                     if (inactiveMaterial != null && gazedAtMaterial != null)
                     {
                         GetComponent <Renderer>().material = gazedAt ? gazedAtMaterial : inactiveMaterial;
                         return;
                     }
                     GetComponent <Renderer>().material.color = gazedAt ? Color.green : Color.red;
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
    //private string health, mana;

    // Use this for initialization
    void Start()
    {
        playerController = player.GetComponent <MP_PlayerController>();

        toDisplay = GetComponent <Text>();

        //camera part
        if (cam == null)
        {
            cam = Camera.main;
        }

        if (cam != null)
        {
            // Tie this to the camera, and do not keep the local orientation.
            transform.SetParent(cam.GetComponent <Transform>(), true);
        }
    }
Exemplo n.º 4
0
 private void Start()
 {
     controller = GetComponentInParent <MP_PlayerController>();
 }