Beispiel #1
0
    public override void Invoke()
    {
        base.Invoke();

        if (addOrRemove == AddOrRemove.Add)
        {
            BehaviorMgr.AddBehavior(originPlayer, targetUnit, behavior);
        }
        else
        {
            BehaviorMgr.RemoveBehavior(targetUnit, behavior);
        }
    }
Beispiel #2
0
    IEnumerator InvokeOrderCor()
    {
        if (order.type == OrderType.move)
        {
            NodeMovingMgr.instance.Event_StartMoving  += StartMoving;
            NodeMovingMgr.instance.Event_ReachTarget  += ReachTarget;
            NodeMovingMgr.instance.Event_MovingToNode += MoveToNode;

            if (order.origin.isWalker)
            {
                //行走
                NodeMovingMgr.instance.MoveObject(order.origin.gameObject, order.path,
                                                  order.origin.UnitActualSpeed, MapCoord.xy);
            }
            else if (TraitManager.PossessTrait(order.origin, "Flying"))
            {
                //飞行
                NodeMovingMgr.instance.MoveObjectFlying(order.origin.gameObject, order.targetNode,
                                                        order.origin.UnitActualSpeed, MapCoord.xy);
            }
            //else if 瞬移

            if (order.origin.RestoreFacing())
            {
                //需要转身
                yield return(new WaitForSeconds(UnitAttackMgr.instance.animTurnbackTime));
            }

            while (NodeMovingMgr.instance.moving)
            {
                yield return(null);
            }

            if (order.origin.RestoreFacing())
            {
                //需要转身
                yield return(new WaitForSeconds(UnitAttackMgr.instance.animTurnbackTime));
            }
        }
        else if (order.type == OrderType.attack)
        {
            //移动后攻击
            if (order.path != null || order.targetNode != null)
            {
                NodeMovingMgr.instance.Event_StartMoving  += StartMoving;
                NodeMovingMgr.instance.Event_ReachTarget  += ReachTarget;
                NodeMovingMgr.instance.Event_MovingToNode += MoveToNode;

                if (order.path != null)
                {
                    NodeMovingMgr.instance.MoveObject(order.origin.gameObject, order.path,
                                                      order.origin.UnitActualSpeed, MapCoord.xy);
                }
                else
                {
                    NodeMovingMgr.instance.MoveObjectFlying(order.origin.gameObject, order.targetNode,
                                                            order.origin.UnitActualSpeed, MapCoord.xy);
                }

                while (NodeMovingMgr.instance.moving)
                {
                    yield return(null);
                }
            }

            //攻击
            UnitAttackMgr.instance.Attack(order.origin, order.target);

            while (UnitAttackMgr.operating)
            {
                yield return(null);
            }
        }
        else if (order.type == OrderType.rangeAttack)
        {
            UnitAttackMgr.instance.Attack(order.origin, order.target, true);

            while (UnitAttackMgr.operating)
            {
                yield return(null);
            }
        }
        else if (order.type == OrderType.wait)
        {
            BattleManager bm = BattleManager.instance;
            bm.AddUnitToActionList(ref bm.waitingUnitList, BattleManager.currentActionUnit, false);
        }
        else if (order.type == OrderType.defend)
        {
            //获得+1/5防御力buff一回合
            BehaviorMgr.AddBehavior(order.origin, BehaviorMgr.GetBehavior("Defend"));
        }

        order = null;
    }