void OnTriggerEnter(Collider col)
    {
        PickupBase Pickup = col.gameObject.GetComponent <PickupBase>();

        if (Pickup)
        {
            Pickup.PickedUp();
        }
        Projectile proj = col.gameObject.GetComponentInParent <Projectile>();

        if (proj && SinceSpawn >= 3)
        {
            Health -= proj.Damage - (proj.WeaponKind == Weapon.Kind ? 1 : 0);
            if (Health <= 0)
            {
                Health += 100;
                Lives--;
                if (Lives == 0)
                {
                    Instantiate(DeathEffect, transform.position, transform.rotation);
                    PlayerBody.SetActive(false);
                    Weapon.Firing = false;
                    MapHandler.Instance.enabled = false;
                }
                SinceSpawn = 0;
            }
            Destroy(col.gameObject);
        }
    }
    protected override void Die()
    {
        List <PickupBase> scraps = new List <PickupBase>();

        for (int i = 0; i < DroppedScrap; i++)
        {
            scraps.Add(PickupManager.Instance.GetScrap());
        }
        Vector3 dropAngle = Vector3.forward * ScrapDropDistance;

        for (int i = 0; i < scraps.Count; i++)
        {
            if (scraps[i] != null)
            {
                scraps[i].transform.position = dropAngle + transform.position;
                dropAngle = Quaternion.AngleAxis(360.0f / scraps.Count, Vector3.up) * dropAngle;
            }
        }

        PickupBase fuel = PickupManager.Instance.GetFuel();

        if (fuel != null)
        {
            fuel.transform.position = transform.position;
        }
        base.Die();
    }
Exemple #3
0
 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.K))
     {
         PickupBase scrap = PickupManager.Instance.GetScrap();
         scrap.transform.position = transform.position;
     }
 }
Exemple #4
0
 protected void placeObject(PickupBase p)
 {
     if (p.moveType == PickupBase.Movement.Dynamic)
     {
         p.setVelocity(new Vector2(Random.Range(-5f, 5f), 3f));
         p.transform.position = transform.position;
     }
     else if (p.moveType == PickupBase.Movement.Static)
     {
         p.transform.position = transform.position + new Vector3(Random.Range(-2, 2), Random.Range(-2, 2));
         p.setVelocity(new Vector3(-5, 0));
     }
     p.Unstuck();
 }
Exemple #5
0
    private void Start()
    {
        _pickup = GetComponentInParent <PickupBase>();
        _text   = GetComponent <TextMeshPro>();

        //The price tag should not be visible if the item is free
        if (_pickup.Price <= 0)
        {
            gameObject.SetActive(false);
        }

        //The index on the sprite of the sprite to display
        const int SPRITE_SHEET_INDEX = 0;

        //Sets the price text
        _text.text = $"{_pickup.Price} <sprite={SPRITE_SHEET_INDEX}> ";
    }
Exemple #6
0
    void Start()
    {
        _label          = GetComponent <TMP_Text>();
        _unformatedText = _label.text;

        _pickup = GetComponentInParent <PickupBase>();

        if (_pickup)
        {
            var weaponPickup = _pickup.GetComponentInChildren <WeaponPickupBase>();

            if (weaponPickup)
            {
                DisplayedWeapon = weaponPickup.GetWeapon();
            }
        }
    }
Exemple #7
0
    private void FillPickupsList()
    {
        PickupManager manager = GameObject.FindObjectOfType <PickupManager>();

        if (manager == null)
        {
            Debug.LogWarning("No PickupManager found!");
            return;
        }
        manager.possiblePickups.Clear();
        foreach (string assetGUID in AssetDatabase.FindAssets("t:GameObject"))
        {
            GameObject go     = AssetDatabase.LoadAssetAtPath <GameObject>(AssetDatabase.GUIDToAssetPath(assetGUID));
            PickupBase pickup = go.GetComponent <PickupBase>();
            if (pickup && pickup.active)
            {
                manager.possiblePickups.Add(pickup);
            }
            continue;
        }
        EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
    }
    void Start()
    {
        _pickupBase = GetComponentInParent <PickupBase>();

        //The interaction text shall not be visible if the player don't have to
        //pick the item up. (if ActivationMode is OnInteraction)
        if (_pickupBase.ActivationMode == PickupBase.PickupActivationMode.OnContact)
        {
            //Disable Interaction text
            gameObject.SetActive(false);
            return;
        }

        TMP = GetComponent <TextMeshPro>();

        //if a controller is connected
        if (Input.GetJoystickNames().Any())
        {
            _controllerConnected = true;
        }

        StartCoroutine(CoBlinkSprite());
    }
Exemple #9
0
 private void PickupBase_onGroundHit(PickupBase.PickupType p)
 {
     switch (p)
     {
         case PickupBase.PickupType.Coin:
             AudioSources.coinHitGround.PlayOneShot(coinHitGround, SFXVol);
             break;
     }
 }
 /// <summary>
 /// Removes the powerup.
 /// </summary>
 /// <param name="powerup">Powerup.</param>
 public void RemovePowerup(PickupBase powerup)
 {
     m_PowerupList.Remove(powerup);
 }
 /// <summary>
 /// Adds the powerup.
 /// </summary>
 /// <param name="powerUp">Power up.</param>
 public void AddPowerup(PickupBase powerUp)
 {
     m_PowerupList.Add(powerUp);
 }
Exemple #12
0
    public void PickupItem()
    {
        // if the current gamemode doesn't have weapons then return
        if (RaceSettings.gamemode == E_GAMEMODES.Survival || RaceSettings.gamemode == E_GAMEMODES.TimeTrial)
            return;

        // if the ship already has a pickup then return
        if (weaponClass != E_WEAPONS.NONE)
            return;

        // get length of weapons enum (minus none at the end)
        int max = System.Enum.GetNames(typeof(E_WEAPONS)).Length - 1;
        int rand = Random.Range(0, max);
        E_WEAPONS weap = (E_WEAPONS)rand;
        switch (weap)
        {
            case E_WEAPONS.AUTOPILOT:
                PickupAutopilot ap = new PickupAutopilot();
                ap.OnInit(0.0f, this, weap);
                pickup = ap;
                break;
            case E_WEAPONS.BOMB:
                PickupBomb bo = new PickupBomb();
                bo.OnInit(0.0f, this, weap);
                pickup = bo;
                break;
            case E_WEAPONS.CANNONS:
                PickupCannons ca = new PickupCannons();
                ca.OnInit(0.0f, this, weap);
                pickup = ca;
                break;
            case E_WEAPONS.CLOAK:
                PickupCloak cl = new PickupCloak();
                cl.OnInit(0.0f, this, weap);
                pickup = cl;
                break;
            case E_WEAPONS.ENERGYWALL:
                PickupEnergyWall ew = new PickupEnergyWall();
                ew.OnInit(0.0f, this, weap);
                pickup = ew;
                break;
            case E_WEAPONS.EPACK:
                PickupEPack ep = new PickupEPack();
                ep.OnInit(0.0f, this, weap);
                pickup = ep;
                break;
            case E_WEAPONS.FSHIELD:
                PickupFShield fs = new PickupFShield();
                fs.OnInit(0.0f, this, weap);
                pickup = fs;
                break;
            case E_WEAPONS.IMPULSE:
                PickupImpulse im = new PickupImpulse();
                im.OnInit(0.0f, this, weap);
                pickup = im;
                break;
            case E_WEAPONS.MINES:
                PickupMines mi = new PickupMines();
                mi.OnInit(0.0f, this, weap);
                pickup = mi;
                break;
            case E_WEAPONS.MISSILES:
                PickupMissiles mis = new PickupMissiles();
                mis.OnInit(0.0f, this, weap);
                pickup = mis;
                break;
            case E_WEAPONS.PLASMABOLT:
                PickupPlasmaBolt pl = new PickupPlasmaBolt();
                pl.OnInit(0.0f, this, weap);
                pickup = pl;
                break;
            case E_WEAPONS.REFLECTOR:
                PickupReflector re = new PickupReflector();
                re.OnInit(0.0f, this, weap);
                pickup = re;
                break;
            case E_WEAPONS.ROCKETS:
                PickupRockets ro = new PickupRockets();
                ro.OnInit(0.0f, this, weap);
                pickup = ro;
                break;
            case E_WEAPONS.SHIELD:
                PickupShield sh = new PickupShield();
                sh.OnInit(0.0f, this, weap);
                pickup = sh;
                break;
            case E_WEAPONS.TRIPLASER:
                PickupTripLaser tl = new PickupTripLaser();
                tl.OnInit(0.0f, this, weap);
                pickup = tl;
                break;
        }
    }
Exemple #13
0
 void setupPickup(PickupBase p)
 {
     p.transform.position = GetPos();
     p.SetMovementType(PickupBase.Movement.Static);
     p.setVelocity(new Vector2(-Random.Range(MinVelocity, MaxVelocity), 0));
 }
Exemple #14
0
 private void Awake()
 {
     PickupBase = GetComponentInParent <PickupBase>();
 }
        public void FireFrom(Fleet fleet)
        {
            var pickup = PickupBase.FireFrom <T>(fleet);

            pickup.TimeDeath = fleet.World.Time + fleet.World.Hook.ShieldCannonballLife;
        }
Exemple #16
0
    private void PickupBase_onPickup(PickupBase.PickupType p)
    {
        switch (p)
        {
            case PickupBase.PickupType.Coin:
                AudioSources.CoinGetsPicked.PlayOneShot(CoinGetsPicked, SFXVol);
                //AudioSource.PlayClipAtPoint(CoinGetsPicked, soundPos, SFXVol);
                break;

            case PickupBase.PickupType.Energy:
                AudioSources.EnergyGetsPicked.PlayOneShot(EnergyGetsPicked, SFXVol);
                //AudioSource.PlayClipAtPoint(EnergyGetsPicked, soundPos, SFXVol);
                break;
        }
    }
Exemple #17
0
    public static void RemoveObject(PickupBase e, bool disableEvents = false)
    {
        if (instance)
        {
            if (instance.ActivePool.Contains(e))
                instance.ActivePool.Remove(e);

            if (!instance.InActivePool.Contains(e))
                instance.InActivePool.Add(e);

            if (e)
            {
                e.transform.position = new Vector3(0, 500, -50);
                e.RemoveFromView(false);
                if (disableEvents)
                    e.unregisterDelegates();
            }

            if (instance.onRemove != null)
                instance.onRemove(e);
        }
    }
Exemple #18
0
 public static void OnPickup(PickupBase p)
 {
     _i._onPickup.Invoke();
 }
Exemple #19
0
    public static PickupBase GetObject(PickupBase.PickupType Type)
    {
        if (instance)
        {
            PickupBase e;
            if (instance.InActivePool.Any(i => i.pType == Type))
            {
                e = instance.InActivePool.First(i => i.pType == Type);
                instance.InActivePool.Remove(e);
                instance.ActivePool.Add(e);
                e.gameObject.SetActive(true);
            }
            else
            {
                //stage Specific location
               // GameObject g = Instantiate(Resources.Load("Object/Pickup/" + Application.loadedLevelName + "/"  + Type.ToString()), Vector3.zero, Quaternion.identity) as GameObject;
                //None Stage Specific
                GameObject g = Instantiate(Resources.Load("Object/Pickup/" + Type.ToString()), Vector3.zero, Quaternion.identity) as GameObject;
                if (g == null)
                    return null;
                g.name = Type.ToString() + " - " + (instance.ActivePool.Count + instance.InActivePool.Count);
                e = g.GetComponent<PickupBase>();

                instance.ActivePool.Add(e);
                e.transform.SetParent(instance.transform, false);
            }

            e.gameObject.SendMessage("startBehaviours");
            return e;
        }
        return null;
    }