Ejemplo n.º 1
0
 /// <summary>
 /// 初始化buff
 /// </summary>
 /// <param name="type"></param>
 /// <param name="time"></param>
 /// <param name="owner"></param>
 /// <param name="value"></param>
 public virtual void OnInit(EnumDefine.BuffType type, float time, MMORPG_BaseObject owner, float value)
 {
     this.m_buffType = type;
     this.m_Time     = time;
     this.m_Owner    = owner;
     this.m_Value    = value;
 }
Ejemplo n.º 2
0
 public Telegram(float time, Transform senderTrans, Transform receiverTrans, int msg, MonoBehaviour mb, float hurt1)
 {
     DispatchTime  = time;
     SenderTrans   = senderTrans;
     ReceiverTrans = receiverTrans;
     Msg           = msg;
     _Behaviour    = mb;
     hurt          = hurt1;
     debufftype    = EnumDefine.DeBuffType.None;
     bufftype      = EnumDefine.BuffType.None;
 }
Ejemplo n.º 3
0
    /// <summary>
    /// 增加buff
    /// </summary>
    /// <param name="type"></param>
    /// <param name="time"></param>
    /// <param name="value"></param>
    public void AddBuff(EnumDefine.BuffType type, float time, float value)
    {
        Debug.Log(this.gameObject.name + "--->:测试增加一个buff" + "--->" + type.ToString());
        MMORPG_BaseBuff buff = m_buffs.Find(x => x.GetBuffType() == type);

        if (buff != null)
        {
            buff.OnInit(type, time, this, value);
        }
        else
        {
            MMORPG_BaseBuff instance = MMORPG_BaseBuff.GetInstance(type);
            instance.OnInit(type, time, this, value);
            this.m_buffs.Add(instance);
        }
    }
Ejemplo n.º 4
0
    /// <summary>
    /// 获得本类实例
    /// </summary>
    /// <returns></returns>
    public static MMORPG_BaseBuff GetInstance(EnumDefine.BuffType type)
    {
        switch (type)
        {
        case EnumDefine.BuffType.Ice:
            return(new MMORPG_Buff_Ice());

        case EnumDefine.BuffType.Fire:
            return(new MMORPG_Buff_Fire());

        case EnumDefine.BuffType.Poison:
            return(new MMORPG_Buff_Poison());

        case EnumDefine.BuffType.Light:
            return(new MMORPG_Buff_Light());

        case EnumDefine.BuffType.Dark:
            return(new MMORPG_Buff_Dark());

        default:
            return(new MMORPG_BaseBuff());
        }
    }
Ejemplo n.º 5
0
    /// <summary>
    /// 在实体之间传递消息
    /// </summary>
    /// <param name="delay">该消息延迟执行的时间</param>
    /// <param name="senderTrans">消息发送者</param>
    /// <param name="receiverTrans">消息接受者</param>
    /// <param name="msg">消息的类型,由一个枚举值转化而来</param>
    /// <param name="_mb">当前游戏实体(就是挂在目标游戏物体上的相应脚本)</param>
    public void DispatchMessage(float delay, Transform senderTrans, Transform receiverTrans, int msg, MonoBehaviour _mb, float hurt1, EnumDefine.BuffType buff, float bfvalue, float bftime)
    {
        // 由接受者的Transform获取它的实体(其实就是对应脚本)
        BaseGameEntity receiver = EntityManager.Instance.GetEntityFromTransform(receiverTrans);
        Telegram       telegram = new Telegram(delay, senderTrans, receiverTrans, msg, _mb, hurt1, buff, bfvalue, bftime);

        if (delay <= 0.0f)
        {
            //Debug.Log("No Delay");
            Discharge(receiver, telegram);
        }
        else
        {
            //Debug.Log("In Delay");
            // 目前经过的时间,从游戏开始之后计算
            float currentTime = Time.realtimeSinceStartup;
            telegram.DispatchTime = currentTime + delay;

            // 查找重复的消息,重复的话就直接return
            foreach (Telegram val in PriorityQ)
            {
                if (val.SenderTrans == senderTrans && val.ReceiverTrans == receiverTrans && val.Msg == msg)
                {
                    return;
                }
            }

            // 一个延时执行的消息队列
            PriorityQ.Add(telegram);
        }
    }
Ejemplo n.º 6
0
 public override void OnInit(EnumDefine.BuffType type, float time, MMORPG_BaseObject owner, float value)
 {
     base.OnInit(type, time, owner, value);
 }