Esempio n. 1
0
 public override void update()
 {
     if (!m_isRunning)
     {
         run();
     }
     if (m_target == null || m_target.state == ActorState.DEAD || m_actor.state == ActorState.DEAD)
     {
         StopMoveEvtArg arg = new StopMoveEvtArg();
         arg.ac = m_actor;
         m_actor.FireEvent(m_actor, EventType.EVT_STOP_MOVE, arg);
         m_bFinished = true;
         return;
     }
     if (Vector3.Distance(m_target.transform.position, m_actor.transform.position) > m_actor.attackRange)
     {
         BeginMoveEvtArg arg = new BeginMoveEvtArg();
         arg.ac       = m_actor;
         arg.position = m_target.transform.position;
         m_actor.FireEvent(m_actor, EventType.EVT_BEGIN_MOVE, arg);
     }
     else
     {
         //Debug.Log("AttackCommand : BeginAttackEvent");
         BeginAttackEvtArg arg = new BeginAttackEvtArg();
         arg.attackerID = m_actor.transform.GetInstanceID();
         arg.targetID   = m_target.transform.GetInstanceID();
         arg.ac         = m_actor;
         arg.target     = m_target;
         m_actor.FireEvent(this, EventType.EVT_BEGIN_ATTACK, arg);
     }
 }
Esempio n. 2
0
        void OnBeginAttack(object sender, EventArgs arg)
        {
            BeginAttackEvtArg e = arg as BeginAttackEvtArg;

            if (this == e.ac)
            {
                if (e.target != null)
                {
                    targetUnit = e.target.transform;
                    agent.SetDestination(transform.position);
                    SetState(new AttackActorState(this, e.target));
                }
            }
        }
Esempio n. 3
0
        public void OnBeAttacked(object sender, EventArgs arg)
        {
            BeginAttackEvtArg e        = arg as BeginAttackEvtArg;
            Transform         attacker = EditorUtility.InstanceIDToObject(e.attackerID) as Transform;
            Transform         sufferer = EditorUtility.InstanceIDToObject(e.targetID) as Transform;

            if (attacker)
            {
                Actor ac = attacker.GetComponent <Actor> ();
                //Debug.Log (ac.creatureName + "开始攻击!");
            }
            if (sufferer)
            {
                Actor ac = sufferer.GetComponent <Actor> ();
                //Debug.Log (ac.creatureName + "正在遭受攻击!");
            }
        }