Esempio n. 1
0
    void Discharge()
    {
        SetCharge(false);
        nextConduit.SetCharge(true);

        GameObject lightningBolt = Instantiate(lightningBoltEffect, halfwayPoint, Quaternion.LookRotation(boltDirection));

        lightningBolt.transform.localScale = new Vector3(lightningBolt.transform.localScale.x, lightningBolt.transform.localScale.y, boltDistance);

        AS.Play();

        //print("blap");
        RaycastHit[] hits = Physics.RaycastAll(transform.position, boltDirection, boltDistance);
        for (int i = 0; i < hits.Length; i++)
        {
            //print("ZAPP");
            HealthSP targetHP = hits[i].transform.gameObject.GetComponent <HealthSP>();
            if (targetHP != null)
            {
                if (targetHP.zappable)
                {
                    targetHP.TakeDamage(1, false);
                }
            }
            if (hits[i].transform.CompareTag("Bomb"))
            {
                hits[i].transform.gameObject.GetComponent <BombSP>().Explode();
            }
        }
    }
Esempio n. 2
0
    void OnTriggerEnter(Collider other)
    {
        print("Explosion has hit " + other.name);
        HealthSP thingHit = other.GetComponent <HealthSP>();

        if (thingHit != null)
        {
            thingHit.TakeDamage(1);
        }
    }
Esempio n. 3
0
 //Damages the player when they collide.
 void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Player") && !dead)
     {
         HealthSP thingHit = other.GetComponent <HealthSP>();
         if (thingHit != null)
         {
             thingHit.TakeDamage(1);
         }
     }
 }
Esempio n. 4
0
    //Damages the player when they collide, and also destroys bombs.
    void OnTriggerEnter(Collider other)
    {
        if (dead)
        {
            return;
        }

        if (other.CompareTag("Player"))
        {
            HealthSP thingHit = other.GetComponent <HealthSP>();
            if (thingHit != null)
            {
                thingHit.TakeDamage(1);
            }
        }

        if (other.CompareTag("Bomb"))
        {
            //Maybe add an eating sound here?
            Destroy(other.gameObject);
        }
    }
Esempio n. 5
0
    void OnTriggerEnter(Collider other)
    {
        print("Projectile hit " + other.name);

        //ignore enemies, because only enemies can fire projectiles.
        if (other.CompareTag("Enemy"))
        {
            return;
        }

        HealthSP thingHit = other.GetComponent <HealthSP>();

        if (thingHit != null)
        {
            if (destroysBlocks || other.gameObject.layer != 8)
            {
                thingHit.TakeDamage(1, false);
            }
        }

        BombSP daBomb = other.GetComponent <BombSP>();

        if (daBomb != null && detonatesBombs)
        {
            Destroy(gameObject);
            daBomb.Explode();
        }

        if (destroyOnHit)
        {
            Destroy(gameObject);
        }

        if (destroyOnBarriers && other.gameObject.layer == 8)
        {
            Destroy(gameObject);
        }
    }
Esempio n. 6
0
    void Awake()
    {
        character = GetComponent <CharacterController>();
        HSP       = GetComponent <HealthSP>();
        animator  = GetComponentInChildren <Animator>();
        bool actuallyChangeColor = true;

        //set player color:
        playerColor = Color.white;

        if (textureSwap != null)
        {
            GetComponentInChildren <Renderer>().material.SetTexture("_MainTex", textureSwap);
        }

        switch (playerNumber)
        {
        case 1:
            actuallyChangeColor = false;
            break;

        case 2:
            actuallyChangeColor = false;
            playerColor         = Color.black;
            break;

        case 3:
            actuallyChangeColor = false;
            playerColor         = Color.red;
            break;

        case 4:
            actuallyChangeColor = false;
            playerColor         = Color.blue;
            break;

        case 5:
            playerColor = Color.yellow;
            break;

        case 6:
            playerColor = Color.magenta;
            break;

        case 7:
            playerColor = Color.cyan;
            break;

        case 8:
            playerColor = Color.green;
            break;
        }

        if (actuallyChangeColor)
        {
            GetComponentInChildren <Renderer>().material.color = playerColor;
        }

        resetStats();
        if (usePreviousStats)
        {
            receiveStats();
        }
        currentLives = lives;

        //special check: depending on the gamecontroller's player number, we might not want to spawn players.
        //The one exception is player 1 themselves if we're playing a singleplayer game.
        print(GameController.instance.versus);
        if (GameController.instance.versus && !GameController.instance.players[playerNumber - 1] && !testingVERSUS)
        {
            gameObject.SetActive(false);
        }
        else if (InputManager.Devices.Count >= playerNumber)
        {
            playerController = InputManager.Devices[playerNumber - 1];
        }
    }