Пример #1
0
    private void Start()
    {
        List <UIBar_Autorefill> b = new List <UIBar_Autorefill>();

        JSONWeapon[] weapons = HandleJSON.GetAllEquippedWeapons();
        playerSpell = new PlayerSpell[weapons.Length - 1];
        bool equippedWeapon = false;

        for (int i = 0; i < weapons.Length; i++)
        {
            if (weapons[i].slot == 0)
            {
                //equip weapon
                Transform w = Instantiate(Resources.Load <Transform>("Weapons/" + weapons[i].item_name), weaponHolder);
                w.localPosition = Vector3.zero;
                w.localRotation = Quaternion.Euler(Vector3.zero);
                equippedWeapon  = true;
            }
            else
            {
                //equip spell
                int index = i;
                if (equippedWeapon)
                {
                    index--;
                }
                playerSpell[index] = Resources.Load <PlayerSpell>("Spells/" + weapons[i].item_name);
            }
        }

        for (int i = 0; i < playerSpell.Length; i++)
        {
            playerSpell[i].motion.Init();
            playerSpell[i].spell.Initialise(this.gameObject);
            UIBar_Autorefill bar = Instantiate(spellPrefab, spellIconContainer);
            bar.GetComponent <Image>().sprite = playerSpell[i].icon;
            bar.SetRefillSpeed(playerSpell[i].spell.timeBetweenUse);
            b.Add(bar);
        }

        autorefills = b.ToArray();

        plane  = new Plane(Vector3.up, 0);
        health = GameObject.FindObjectOfType <Health_Player>();
        health.Init();
        health.InitHealth(100);
        UnitManager.instance.AddHealthPlayer(health);
    }
Пример #2
0
 private void OnTriggerEnter2D(Collider2D coll)
 {
     if (coll.gameObject.tag.Equals("Player"))
     {
         Health_Player Player = coll.gameObject.GetComponent <Health_Player>();
         Player.DamagePlayer(10);
         Destroy(this.gameObject);
     }
     if (coll.gameObject.tag.Equals("Default"))
     {
         Destroy(this.gameObject);
     }
     else
     {
         Destroy(this.gameObject, 5f);
     }
 }
Пример #3
0
 void Start()
 {
     health = GameObject.FindObjectOfType <Health_Player>();
 }