Ejemplo n.º 1
0
    void OnTriggerStay2D(Collider2D other)
    {
        PickupRespawn pickup = other.GetComponent <PickupRespawn> ();

        if (pickup == null)
        {
            return;
        }
        if (!pickup.active)
        {
            return;
        }
        pickup.SetAButton(true);
        if (other.GetComponent <AmmoPickup> () != null)
        {
            PickUpAmmo(pickup);
        }
        else if (other.GetComponent <PickupGun> () != null)
        {
            if (Input.GetButtonDown("aButton_" + playerTag.Id.ToString()))
            {
                PickUpWeapon(pickup);
            }
        }
    }
Ejemplo n.º 2
0
    void PickUpAmmo(PickupRespawn pickup)
    {
        int extraAmmo = pickup.GetComponent <AmmoPickup> ().Value;

        Base_Weapon ammoWeapon = currentWeapon;         // if lemon -- refill secondary : if weapon is full, return, else fill.

        if (currentWeapon.HasUnlimitedAmmo)
        {
            ammoWeapon = (currentWeapon == primaryWeapon ? secondaryWeapon : primaryWeapon);
        }

        if (ammoWeapon.IsFull)
        {
            return;
        }

        ammoWeapon.AddAmmo(extraAmmo);

        if (playerUI != null)
        {
            playerUI.UpdateAmmoCounter(currentWeapon.Ammo, currentWeapon.MaxAmmo);
        }

        pickup.StartRespawnTimer();
    }
Ejemplo n.º 3
0
    void PickUpWeapon(PickupRespawn pickup)
    {
        if (currentWeapon == primaryWeapon)
        {
            primaryWeapon = null;
        }
        else
        {
            secondaryWeapon = null;
        }

        Destroy(currentWeapon);
        currentWeapon = null;
        {
            GameObject temp = Instantiate(pickup.GetComponent <PickupGun> ().gun, transform);
            currentWeapon = temp.GetComponent <Base_Weapon> ();
        }

        if (primaryWeapon == null)
        {
            primaryWeapon = currentWeapon;
        }
        else
        {
            secondaryWeapon = currentWeapon;
        }

        currentWeapon.GetComponent <PlayerTag>().SetId(GetPlayerTag().Id);
        currentWeapon.GetComponent <PlayerTag>().SetTeam(GetPlayerTag().Team);

        UpdateAmmoUI(currentWeapon.Ammo, currentWeapon.MaxAmmo, !currentWeapon.HasUnlimitedAmmo);

        pickup.StartRespawnTimer();
    }
Ejemplo n.º 4
0
    public void InstantiateObject()
    {
        GameObject objectToInstantiate = Instantiate(options [currentOption].prefab, transform.position, Quaternion.identity);

        if (options [currentOption].type == PlayerDeadOptionType.MOB)
        {
            Base_Mob mob = objectToInstantiate.GetComponent <Base_Mob> ();
            mob.Ini(null, playerTag.Id, playerTag.Team, true);
        }
        else if (options [currentOption].type == PlayerDeadOptionType.POWERUP)
        {
            PickupRespawn pickup = objectToInstantiate.GetComponent <PickupRespawn> ();
            pickup.duration = -1f;

            PickupGun gun = objectToInstantiate.GetComponent <PickupGun> ();
            if (gun != null)
            {
                return;
            }

            Powerup powerup = objectToInstantiate.GetComponent <Powerup> ();
            if (powerup != null)
            {
                powerup.SetValue(options[currentOption].baseValue);
                return;
            }

            AmmoPickup ammo = objectToInstantiate.GetComponent <AmmoPickup> ();
            if (ammo != null)
            {
                ammo.SetValue((int)options [currentOption].baseValue);
                return;
            }
        }
    }
Ejemplo n.º 5
0
    //I addapted this code from the youtuber Brackeys
    void CheckAmmo()
    {
        //getting a reference to the movement so that the target can be set to the ammo and to the nav mesh so that the stopping distance can be changed to 0 so the AI will walk all the way to the pickup
        EnemyMovement movement = GetComponent <EnemyMovement>();


        GameObject player = GameObject.FindGameObjectWithTag("Player");

        if (curAmmo <= maxAmmo - 5 || player == null)
        {
            //making variables and arrays that store the information of the ammo pickups so that the AI can seek them out
            GameObject[] ammoPickups = GameObject.FindGameObjectsWithTag("AmmoPickup");
            float        disToAmmo;
            float        shortestDis   = Mathf.Infinity;
            GameObject   closestPickup = null;


            //checking all of the ammoPickups and checking the distance for each from the AI and finding the closest
            foreach (GameObject pickup in ammoPickups)
            {
                disToAmmo = Vector3.Distance(transform.position, pickup.transform.position);
                if (disToAmmo <= shortestDis)
                {
                    closestPickup = pickup;
                    shortestDis   = disToAmmo;
                }
            }

            PickupRespawn respawn = closestPickup.GetComponent <PickupRespawn>();
            if (respawn.itemGot == false)
            {
                shouldFire = false;
                isEnemy    = false;
                movement.ChangeDistance(0);
                movement.target = closestPickup.transform;
            }
            else
            {
                isEnemy         = true;
                shouldFire      = true;
                movement.target = null;
                movement.AquireTarget();
                movement.ChangeDistance(movement.toFar);
            }
        }
        else
        {
            isEnemy         = true;
            movement.target = null;
            test            = true;
            shouldFire      = true;
            movement.AquireTarget();
            movement.ChangeDistance(movement.toFar);
        }
    }
Ejemplo n.º 6
0
    void OnTriggerEnter2D(Collider2D other)
    {
        PickupRespawn pickup = other.GetComponent <PickupRespawn> ();

        if (pickup != null && pickup.active)
        {
            GameObject temp  = Instantiate(brainMobPrefab, transform.position, Quaternion.identity) as GameObject;
            Mob_Skeel  skeel = temp.GetComponent <Mob_Skeel> ();
            skeel.Ini(null, playerTag.Id, playerTag.Team, true);
            pickup.StartRespawnTimer();
        }
    }
Ejemplo n.º 7
0
    void OnTriggerExit2D(Collider2D other)
    {
        PickupRespawn pickup = other.GetComponent <PickupRespawn> ();

        if (pickup == null)
        {
            return;
        }
        if (!pickup.active)
        {
            return;
        }
        pickup.SetAButton(false);
    }
Ejemplo n.º 8
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (GetComponent <PlayerController>().IsJuggernaut)
        {
            return;
        }
        if (other.tag == "EnemyPickup")
        {
            if (CheckForPanko())
            {
                return;
            }

            if (enemy_count >= enemyMax)
            {
                return;
            }
            PickupRespawn pickupRespawn = other.GetComponent <PickupRespawn> ();
            if (!pickupRespawn.active)
            {
                return;
            }
            EnemyPickup pickup = other.GetComponent <EnemyPickup> ();
            pickupRespawn.StartRespawnTimer();
            other.GetComponent <CircleCollider2D>().enabled = false;

            int r = pickup.enemy;
            if (pickup.random)
            {
                r = (int)Random.Range(0f, enemies_prefabs.Length);
            }
            if (GameManager.gameMode == GAMEMODE.PVP)
            {
                if (r == 0)
                {
                    GameManager.score += 50f;
                }
                else if (r == 1)
                {
                    GameManager.score += 25f;
                }
                else
                {
                    GameManager.score += 100f;
                }
            }
            GiveEnemy(r);
        }
    }
Ejemplo n.º 9
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.GetComponent <ArmorPickup> () != null)
     {
         PickupRespawn pickup = other.GetComponent <PickupRespawn> ();
         if (!pickup.active)
         {
             return;
         }
         armor += other.GetComponent <ArmorPickup> ().Value;
         if (armor > 1f)
         {
             armor = 1f;
         }
         pickup.StartRespawnTimer();
         playerUI.UpdateHealthUI(health, armor);
     }
 }
Ejemplo n.º 10
0
 private void OnTriggerEnter(Collider other)
 {
     //checking if the other object is the player
     if (other.gameObject.tag == "Player")
     {
         //getting the script information from the player
         Throw ammo = other.gameObject.GetComponent <Throw>();
         //checking if the player is at max ammo
         if (ammo.curAmmo < ammo.maxAmmo)
         {
             //calling the GainAmmo method passing the ammoAmount variable as an argument
             ammo.GainAmmo(ammoAmount);
             //getting the code for the item's respawn point then settign the got item bool to true
             PickupRespawn respawn = spawn.GetComponent <PickupRespawn>();
             respawn.itemGot = true;
             //removing the pickup
             Destroy(this.gameObject);
         }
     }
     if (other.gameObject.tag == "Enemy")
     {
         //getting the script information from the player
         EnemyThrow enemyAmmo = other.gameObject.GetComponent <EnemyThrow>();
         //checking if the player is at max ammo
         if (enemyAmmo.curAmmo < enemyAmmo.maxAmmo)
         {
             //calling the GainAmmo method passing the ammoAmount variable as an argument
             enemyAmmo.GainAmmo(ammoAmount);
             //getting the code for the item's respawn point then settign the got item bool to true
             PickupRespawn respawn = spawn.GetComponent <PickupRespawn>();
             respawn.itemGot = true;
             //removing the pickup
             Destroy(this.gameObject);
         }
     }
 }
Ejemplo n.º 11
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (GetComponent <PlayerController> ().IsJuggernaut)
        {
            return;
        }
        if (GetComponent <PlayerEnemyHandler> ().CheckForPanko())
        {
            return;
        }
        PickupRespawn pickupRespawn = other.GetComponent <PickupRespawn> ();

        if (pickupRespawn == null)
        {
            return;
        }
        if (!pickupRespawn.active)
        {
            return;
        }

        Powerup otherPowerup = other.GetComponent <Powerup> ();

        if (otherPowerup == null)
        {
            return;
        }
        {
            Powerup currentPowerup = GetComponent <Powerup> ();
            if (currentPowerup != null)
            {
                if (currentPowerup.CanStack)
                {
                    if (!otherPowerup.CanStack)
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }
        }
        Powerup thisPowerup = null;

        switch (otherPowerup.type)
        {
        case POWERUP_TYPE.DAMAGE:
            thisPowerup = gameObject.AddComponent <Powerup_Damage> ();
            break;

        case POWERUP_TYPE.SPEED:
            thisPowerup = gameObject.AddComponent <Powerup_Movement> ();
            break;

        case POWERUP_TYPE.HEALTH:
            thisPowerup = gameObject.AddComponent <Powerup_Health> ();
            break;
        }
        if (thisPowerup == null)
        {
            return;
        }
        thisPowerup.Copy(otherPowerup);
        StartCoroutine(UsePowerup(thisPowerup));
        pickupRespawn.StartRespawnTimer();
    }
Ejemplo n.º 12
0
    void OnTriggerStay2D(Collider2D other)
    {
        if (type == 2)           // PINKO PANKO
        {
            if (other.tag == "EnemyPickup" || other.tag == "Powerup")
            {
                PickupRespawn otherPickup = other.GetComponent <PickupRespawn> ();
                if (!otherPickup.active)
                {
                    return;
                }
                otherPickup.StartRespawnTimer();

                GameObject  temp             = Instantiate(brainProjectilePrefab, transform.position, Quaternion.identity);
                EnemyScript projectileScript = temp.GetComponent <EnemyScript> ();

                temp.GetComponentInChildren <SpriteRenderer> ().color = GetComponent <SpriteRenderer> ().color;               // SETUP
                projectileScript.id     = id;
                projectileScript.hp     = 50f;
                projectileScript.hp_max = 50f;

                projectileScript.playerObject = null;                 // SET TO CHASE.
                projectileScript.team         = team;


                Color col = Color.white;
                if (id == 1)
                {
                    col = Color.blue;
                }
                else if (id == 2)
                {
                    col = Color.yellow;
                }
                else if (id == 3)
                {
                    col = Color.red;
                }
                else if (id == 4)
                {
                    col = Color.magenta;
                }

                projectileScript.outlineSprite.color = col;

                GameObject[] temp2 = GameObject.FindGameObjectsWithTag("Player");                 // Ignore player colilsion
                for (int i = 0; i < temp2.Length; i++)
                {
                    MovementScript playerMov = temp2 [i].GetComponent <MovementScript> ();
                    if (playerMov.player_num == id)
                    {
                        Physics2D.IgnoreCollision(temp2[i].GetComponent <CapsuleCollider2D>(), projectileScript.GetComponent <CircleCollider2D>());
                    }
                }
            }
        }
        else if (can_hit)            // Everything Else
        {
            EnemyScript enemy = other.GetComponent <EnemyScript> ();
            if (enemy == null)
            {
                return;
            }
            if (team != 0 && enemy.team == team)
            {
                return;
            }
            if (enemy.id != id)
            {
                float damage;

                if (type == 0)
                {
                    damage    = 10f;
                    enemy.hp -= 10f;
                }
                else
                {
                    damage    = 75f;
                    enemy.hp -= 75f;                     // TANKS DO DAMAGE VS MOBS
                }

                enemy.CreateNumber(enemy.transform.position, damage.ToString(), new Color(1f, .9f, .9f), .1f, 120f, 2f);
                enemy.StartCoroutine(enemy.FlashRoutine());
                enemy.particleSystems[1].Play();
                enemy.audioManager.Play(0);
            }
            StartCoroutine(HitRoutine());
        }
    }
Ejemplo n.º 13
0
    void OnTriggerEnter2D(Collider2D other)
    {
        int team = parentEnemy.team;

        if (parentEnemy.type == 0)           // SKEEL
        {
            MovementScript otherMov = other.GetComponent <MovementScript> ();
            if (otherMov == null)             // if doesnt have a mov script, dont use a null one
            {
                return;
            }
            if (team != 0 && otherMov.team == team)
            {
                return;
            }
            if (otherMov.player_num != parentEnemy.id)               // if not our player, follow.
            {
                parentEnemy.state        = STATE.CHASE;
                parentEnemy.targetObject = other.gameObject;
            }
        }
        else if (parentEnemy.type == 1)                                 // SWOL
        {
            EnemyScript otherEne = other.GetComponent <EnemyScript> (); // CHASESE NEMY
            if (otherEne != null)
            {
                if (team != 0 && otherEne.team == team)
                {
                    return;
                }
                if (otherEne.id != parentEnemy.id)
                {
                    parentEnemy.state        = STATE.CHASE;
                    parentEnemy.targetObject = other.gameObject;
                }
            }
            else
            {
                BulletScript otherBul = other.GetComponent <BulletScript> ();                // CHASES BULLET
                if (otherBul == null)
                {
                    return;
                }
                if (team != 0 && otherBul.team == team)
                {
                    return;
                }
                if (otherBul.id != parentEnemy.id)
                {
                    parentEnemy.state        = STATE.CHASE;
                    parentEnemy.targetObject = other.gameObject;
                }
            }
        }
        else if (parentEnemy.type == 2)                 //PINKO PANKO
        {
            PickupRespawn otherPickup = other.GetComponent <PickupRespawn>();

            if (otherPickup == null)
            {
                return;
            }

            if (!otherPickup.active)
            {
                return;
            }

            parentEnemy.state        = STATE.CHASE;
            parentEnemy.targetObject = other.gameObject;
        }
    }