Beispiel #1
0
 public void Bind(Crafter crafter)
 {
     _crafter = crafter;
     CraftButton.onClick.AddListener(() =>
     {
         var ammo = _crafter.Craft();
         if (ammo == AmmoType.None)
         {
             AboveText.Show("invalid combination", 2, Color.red);
         }
         else
         {
             foreach (Transform t in SlotParent)
             {
                 Destroy(t.gameObject);
             }
             AboveText.Show("Crafted " + ammo.ToString(), 2, Color.green);
             Cannon.SetTrigger("shoot");
             Observable.Timer(TimeSpan.FromSeconds(.25f)).Subscribe(ev =>
             {
                 var sp = Instantiate(Spark, AmmoPoint.position, Quaternion.identity);
                 Destroy(sp, 1);
                 var proj  = Instantiate(AmmoPrefab, AmmoPoint.position, Quaternion.identity).GetComponent <Projectile>();
                 proj.Type = ammo;
             });
         }
     });
 }
Beispiel #2
0
 // Update is called once per frame
 void Update()
 {
     if (_curItem != null)
     {
         if (Input.GetKeyDown("x")) //cursed branching lol
         {
             if (Inventory.AddItem(_curItem.Item))
             {
                 Destroy(_curItem.gameObject);
                 _curItem = null;
                 AboveText.Hide();
             }
             else
             {
                 AboveText.Show("Inventory full", 2, Color.red);
             }
         }
     }
 }
    public void Damage(AmmoType ammo)
    {
        // cursed damage check :(
        int dmg = 0;

        if (Type == MinionType.Animal)
        {
            if (ammo == AmmoType.DevilsHorn)
            {
                dmg = 1;
            }
            else if (ammo == AmmoType.PoseiodonsTrident)
            {
                dmg = 1;
            }
            else if (ammo == AmmoType.PickleRock)
            {
                dmg = 1;
            }
            else if (ammo == AmmoType.MedusasHair)
            {
                dmg = 1;
            }
            else if (ammo == AmmoType.CindirellasShoe)
            {
                dmg = 1;
            }
            else if (ammo == AmmoType.ThorsHammer)
            {
                dmg = 1;
            }
            else if (ammo == AmmoType.UnicornsHorn)
            {
                dmg = 1;
            }
            else if (ammo == AmmoType.LeprechaunsGold)
            {
                dmg = -1;
            }
        }
        else if (Type == MinionType.Zombie)
        {
            if (ammo == AmmoType.DevilsHorn)
            {
                dmg = -1;
            }
            else if (ammo == AmmoType.PoseiodonsTrident)
            {
                dmg = 1;
            }
            else if (ammo == AmmoType.PickleRock)
            {
                dmg = 0;
            }
            else if (ammo == AmmoType.MedusasHair)
            {
                dmg = 0;
            }
            else if (ammo == AmmoType.CindirellasShoe)
            {
                dmg = 0;
            }
            else if (ammo == AmmoType.ThorsHammer)
            {
                dmg = 1;
            }
            else if (ammo == AmmoType.UnicornsHorn)
            {
                dmg = 1;
            }
            else if (ammo == AmmoType.LeprechaunsGold)
            {
                dmg = 1;
            }
            else if (ammo == AmmoType.ZeusThunder)
            {
                dmg = -3;
            }
            else if (ammo == AmmoType.SultansDinner)
            {
                dmg = 3;
            }
            else if (ammo == AmmoType.DieticiansPlate)
            {
                dmg = 0;
            }
            else if (ammo == AmmoType.HerasWrath)
            {
                dmg = 1;
            }
            else if (ammo == AmmoType.ThePowerOfLove)
            {
                dmg = -1;
            }
            else if (ammo == AmmoType.CatTickler)
            {
                dmg = 2;
            }
        }
        else if (Type == MinionType.Plant)
        {
            if (ammo == AmmoType.DevilsHorn)
            {
                dmg = 1;
            }
            else if (ammo == AmmoType.PoseiodonsTrident)
            {
                dmg = 0;
            }
            else if (ammo == AmmoType.PickleRock)
            {
                dmg = 1;
            }
            else if (ammo == AmmoType.MedusasHair)
            {
                dmg = -1;
            }
            else if (ammo == AmmoType.CindirellasShoe)
            {
                dmg = -1;
            }
            else if (ammo == AmmoType.ThorsHammer)
            {
                dmg = 0;
            }
            else if (ammo == AmmoType.UnicornsHorn)
            {
                dmg = 0;
            }
            else if (ammo == AmmoType.LeprechaunsGold)
            {
                dmg = 0;
            }
            else if (ammo == AmmoType.ZeusThunder)
            {
                dmg = 0;
            }
            else if (ammo == AmmoType.SultansDinner)
            {
                dmg = 0;
            }
            else if (ammo == AmmoType.DieticiansPlate)
            {
                dmg = -2;
            }
            else if (ammo == AmmoType.HerasWrath)
            {
                dmg = 3;
            }
            else if (ammo == AmmoType.ThePowerOfLove)
            {
                dmg = -1;
            }
            else if (ammo == AmmoType.CatTickler)
            {
                dmg = -3;
            }
        }

        if (dmg < 0)
        {
            AboveText.Show("healed", 1.5f, Color.green);
        }
        else if (dmg == 0)
        {
            AboveText.Show("no effect", 1.5f, Color.blue);
        }
        else
        {
            AboveText.Show("damaged", 1.5f, Color.red);
        }

        Health -= dmg;
        if (Health > _maxHealth)
        {
            Health = _maxHealth;
        }
        _bar.fillAmount = (float)Health / _maxHealth;
        if (Health <= 0)
        {
            _dead = true;
            if (FindObjectsOfType <minionControl>().Length == 1)
            {
                FindObjectOfType <Core>().LevelWin();
            }
            StartCoroutine(Dissolve());
        }
    }