Example #1
0
    void Shoot(GamerController mainGameController, CharacterObject currentPlayer, int currentPlayerIndex, int opponentIndex)
    {
        // This is the ray which will hit the target
        RaycastHit hit;

        // This is for the effect of shooting
        muzzleFlash.Play();
        AudioClip clip = gunshot.clip;

        gunshot.PlayOneShot(clip);

        // Updates the stamina of the player
        mainGameController.UpdateEnergy(0.5f);

        // This condition is true only when we have hit something with our ray
        if (Physics.Raycast(this.gameObject.transform.position, this.gameObject.transform.forward, out hit, Range))
        {
            if (hit.transform.tag == "Player")
            {
                // This causes damage
                mainGameController.TakeDamage(opponentIndex);
            }
        }
        else
        {
            //Debug.Log("We didn't hit anything but we fired !!!");
        }
    }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        if (CrossPlatformInputManager.GetButtonDown("CannonShoot"))
        {
            GameObject cannon = gameObject.transform.parent.gameObject;
            if (cannon.name.Equals("Cannon" + Cannons.cannonSelected))
            {
                ShootCannon();

                GamerController mainGameController = GetGameController();
                // Updates the stamina of the player
                mainGameController.UpdateEnergy(40f);
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (CrossPlatformInputManager.GetButtonDown("Fire"))
        {
            /*GamerController mainGameController = GetGameController();
             * int currentPlayerIndex = mainGameController.GetCurrentPlayerIndex();
             *
             * Debug.Log("Here we have index:"+currentPlayerIndex);*/

            GamerController mainGameController = GetGameController();
            CharacterObject currentObject      = mainGameController.GetCurrentCharacterObject();

            // Fire only when both are originating from the same object
            if (/*canFireCheck(currentObject) && */ currentObject.weaponName.Equals("Grenade"))
            {
                currentObject.charActions.Attack();
                ThrowGrenade();
                mainGameController.UpdateEnergy(20f);
            }
        }
    }