Beispiel #1
0
    public static ChangeLifeLabel CreateChangeLifeLabel(Vector3 worldPos, Color c, string txt)
    {
        if (labelPrefab == null)
        {
            labelPrefab = Resources.Load("Prefabs/UI/ChangeLifeLabel") as GameObject;
        }

        GameObject labelgo = NGUITools.AddChild(InGameManager.GetInstance().inGameUIManager.gameUICanvas, labelPrefab);

        ChangeLifeLabel unit = labelgo.GetComponent <ChangeLifeLabel>();

        unit.basePos = worldPos;

        unit.SetLabel(c, txt);

        return(unit);
    }
Beispiel #2
0
    /// <summary>
    /// Hurt the specified source, val, comborate, comboval and strike.
    /// </summary>
    /// <returns>The hurt.</returns>
    /// <param name="source">Source.</param>
    /// <param name="val">Value.</param>
    /// <param name="comborate">Comborate.</param>
    /// <param name="comboval">Comboval.</param>
    /// <param name="strike">是否穿透攻击.</param>
    public bool Hurt(InGameBaseObj source, int val, float comborate, float comboval, bool strike)
    {
        float overval = val;


        if (UnityEngine.Random.Range(0f, 100f) < propertys.GetProperty(enCharacterProperty.avoid))
        {
            ChangeLifeLabel.CreateChangeLifeLabel(transform.position +
                                                  new Vector3(0, this.boxSize.y + 0.2f, 0), Color.yellow, "闪避");
            return(false);
        }

        bool iscombo = false;

        if (UnityEngine.Random.Range(0f, 100f) < comborate)
        {
            overval += overval * comboval / 100f;
            iscombo  = true;
        }

        if (!strike)
        {
            float armor = propertys.GetProperty(enCharacterProperty.armor) * 0.06f;
            armor    = (armor / (armor + 1));
            overval -= overval * armor;
            if (overval < 0)
            {
                overval = 0;
            }
        }

        float returnval = overval * (propertys.GetProperty(enCharacterProperty.returnhurt) / 100f);

        overval -= returnval;

        ((InGameBaseCharacter)source).ChangeLife(this, -(int)returnval, false);
        ((InGameBaseCharacter)source).AtkHurt(source, (int)overval);

        EventData.CreateEvent(EventID.EVENT_GAME_CHARACTER_HURT).
        AddData(source, this, -(int)overval).Send();

        return(ChangeLife(source, -(int)Math.Ceiling(overval), iscombo));
    }
Beispiel #3
0
    //生命值变化
    public bool ChangeLife(InGameBaseObj source, int val, bool iscombo)
    {
        if (val == 0)
        {
            return(false);
        }
        float maxlife = propertys.GetProperty(enCharacterProperty.life);

        life = Mathf.Clamp(life + val, 0, maxlife);

        if (life <= 0)
        {
            SetDie(false);
            killMe = source;
            EventData.CreateEvent(EventID.EVENT_GAME_CHARACTER_DIE).AddData(this).Send();
        }
        Color c;

        if (val > 0)
        {
            c = Color.green;
        }
        else
        {
            if (iscombo)
            {
                c = Color.red;
            }
            else
            {
                c = Color.yellow;
            }
        }
        ChangeLifeLabel.CreateChangeLifeLabel(transform.position +
                                              new Vector3(0, this.boxSize.y + 0.2f, 0), c, val + "");

        EventData.CreateEvent(EventID.EVENT_DATA_CHANGELIFE).
        AddData(this).Send();
        return(true);
    }