Exemple #1
0
        public void OnBeDamaged(object sender, EventArgs arg)
        {
            BeDamageEvtArg e = arg as BeDamageEvtArg;

            if (GetInstanceID() != e.descUnitID)
            {
                return;
            }
            life -= e.value;
            GameObject obj        = EditorUtility.InstanceIDToObject(e.srcUnitID) as GameObject;
            string     attackName = "";

            if (obj)
            {
                attackName = obj.name;
            }
            //Debug.Log ("遭受到来自"+attackName+"的"+e.value+"点伤害");
            Global.Println("遭受到来自" + attackName + "的" + e.value + "点伤害");
            if (life <= 0)
            {
                UnitDieEvtArg ueArg = new UnitDieEvtArg();
                ueArg.deadUnitID = GetInstanceID();
                ueArg.murdererID = e.srcUnitID;
                ueArg.deadUnit   = this.gameObject.GetComponent <Actor> ();
                if (obj != null)
                {
                    ueArg.killerUnit = obj.gameObject.GetComponent <Actor> ();
                }
                FireEvent(this, EventType.EVT_UNIT_DIE, ueArg);
            }
        }
Exemple #2
0
        void OnDead(object sender, EventArgs arg)
        {
            UnitDieEvtArg e = arg as UnitDieEvtArg;

            if (e.deadUnit == this)
            {
                SetState(new DeadActorState(this));
            }
        }