Beispiel #1
0
    public void Damage(float hp)
    {
        currHp = Mathf.Clamp(currHp - hp, 0, maxHp);
        RootContext.Instance.Player.HpMax = maxHp;
        RootContext.Instance.Player.HpPct = currHp / (float)maxHp;

        if (hp > 0)
        {
            IgoPoolManager.Spawn <BloodEffect>(transform.position, Quaternion.identity);
        }

        var guiLbl = GuiPoolManager.Spawn <GuiLbl>(transform.position + Vector3.up * (50 + Random.Range(0, 50)), Quaternion.identity).GetComponent <GuiLbl>();

        guiLbl.Init(Color.red, ((int)hp).ToString());

        if (currHp == 0)
        {
            ReSpawnFromDead();

            for (int i = 0; i < 5; i++)
            {
                var point =
                    IgoPoolManager.Spawn <LightPointEffect>(transform.position, Quaternion.identity)
                    .GetComponent <LightPointEffect>();

                point.Init(5, Random.Range(0.2f, 0.7f), Random.Range(-0.4f, -0.1f),
                           new Vector2(Random.Range(-2f, 2), Random.Range(5f, 2)));
            }

            // GameObjectPoolManager.Spawn<BloodDeadEffect>(transform.position, Quaternion.identity);
            var dead   = GameObject.Instantiate(DeadObj, transform.position, Quaternion.identity);
            var parent = GameObject.Find("Units");
            dead.transform.parent = parent.transform;
        }
    }
Beispiel #2
0
    public void OnInject()
    {
        PrefubManager.InitPlayer(Player);
        PrefubManager.InitUnits(Units);
        PrefubManager.InitItems(Items);
        TargetManager.Init();
        GuiPoolManager.SetPool(GuiPool.guiPool);

        MapGenerator.StartApplication();
    }
Beispiel #3
0
    public void AddBagItem(IItem item)
    {
        // Debug.LogError( "AddBagItem " + item.Count);

        var guiLbl = GuiPoolManager.Spawn <GuiLbl>(TargetManager.PlayerController.transform.position + Vector3.up * (50), Quaternion.identity).GetComponent <GuiLbl>();

        guiLbl.Init(item.GetName(), item.Count);

        int  key       = -1;
        bool isNewItem = false;

        if (item.IsCountKit())
        {
            foreach (var keyval in items)
            {
                var other = keyval.Value;
                if (other != null && item.IsEqualType(other))
                {
                    other.Count += item.Count;
                    key          = keyval.Key;
                    break;
                }
            }
        }


        if (key == -1)
        {
            for (int i = 1; i <= 45; i++)
            {
                if (items[i] == null)
                {
                    key       = i;
                    items[i]  = item;
                    isNewItem = true;
                    break;
                }
            }
        }

        if (isNewItem && key != -1 && playerModel.UseItemIndex == key)
        {
            playerModel.UseItem(key);
        }

        RootContext.Instance.Player.UpdateBag(this);
    }