Beispiel #1
0
    public void AddOrder(AgentOrder order)
    {
        Owner.WorldState.SetWSProperty(E_PropKey.E_ORDER, order.Type);
        switch (order.Type)
        {
        case AgentOrder.E_OrderType.E_GOTO:
            Owner.WorldState.SetWSProperty(E_PropKey.E_AT_TARGET_POS, false);
            DesiredDirection  = order.Direction;
            DesiredPosition   = order.Position;
            MoveSpeedModifier = order.MoveSpeedModifier;
            break;

        case AgentOrder.E_OrderType.E_STOPMOVE:
            Owner.WorldState.SetWSProperty(E_PropKey.E_AT_TARGET_POS, true);
            DesiredPosition = order.Position;
            break;

        case AgentOrder.E_OrderType.E_ATTACK:
            bool inRange = order.Target == null || (order.Target.Position - Owner.Position).magnitude <= WeaponRange;
            Owner.WorldState.SetWSProperty(E_PropKey.E_IN_WEAPONS_RANGE, inRange);
            DesiredTarget      = order.Target;
            DesiredAttackType  = order.AttackType;
            DesiredAttackPhase = order.AnimAttackData;
            break;

        default:
            break;
        }

        AgentOrderFactory.Return(order);
    }
Beispiel #2
0
    public void Reset()
    {
        m_ActiveActions.Clear();

        //  Stop = false;
        MotionType     = E_MotionType.None;
        WeaponState    = E_WeaponState.NotInHands;
        WeaponToSelect = E_WeaponType.None;

        Speed = 0;

        Health = MaxHealth;

        Rage      = RageMin;
        Dodge     = DodgeMin;
        Fear      = FearMin;
        IdleTimer = 0;

        MoveDir = Vector3.zero;

        DesiredPosition  = Vector3.zero;
        DesiredDirection = Vector3.zero;

        InteractionObject = null;
        Interaction       = E_InteractionType.None;

        DesiredAnimation = "";

        DesiredTarget     = null;
        DesiredAttackType = E_AttackType.None;

        DontUpdate = false;
    }
Beispiel #3
0
    private void CreateOrderAttack(E_AttackType type)
    {
        if (CouldBufferNewOrder() == false && CouldAddnewOrder() == false)
        {
            //Debug.Log(Time.timeSinceLevelLoad + " attack order rejected, already buffered one ");
            return;
        }

        AgentOrder order = AgentOrderFactory.Create(AgentOrder.E_OrderType.E_ATTACK);

        if (InputDirection != Vector3.zero)   //Controls.Joystick.Direction != Vector3.zero)
        {
            order.Direction = InputDirection; //Controls.Joystick.Direction;
        }
        else
        {
            order.Direction = Transform.forward;
        }


        order.AnimAttackData = ProcessCombo(type);

        order.Target = GetBestTarget(false);

        if (CouldAddnewOrder())
        {
            //Debug.Log("order " + (order.Target != null ? order.Target.name : "no target") + " " + order.AnimAttackData.AnimName);
            Owner.BlackBoard.OrderAdd(order);
        }
        else
        {
            //Debug.Log("order to queue " + (order.Target != null ? order.Target.name : "no target") + " " + order.AnimAttackData.AnimName);
            BufferedOrders.Enqueue(order);
        }
    }
Beispiel #4
0
    private void CreateOrderAttack(E_AttackType type)
    {
        if (CouldBufferNewOrder() == false && CouldAddnewOrder() == false)
        {
            return;
        }

        AgentOrder order = AgentOrderFactory.Create(AgentOrder.E_OrderType.E_ATTACK);

        if (MoveDirection != Vector3.zero)
        {
            order.Direction = MoveDirection;
        }
        else
        {
            order.Direction = Transform.forward;
        }


        order.AnimAttackData = ProcessCombo(type);

        order.Target = MissionZone.Instance.GetBestTarget(Agent, LastAttacketTarget);;

        if (CouldAddnewOrder())
        {
            Agent.BlackBoard.AddOrder(order);
        }
        else
        {
            BufferedOrders.Enqueue(order);
        }
    }
Beispiel #5
0
 public override void Reset()
 {
     base.Reset();
     Target          = null;
     IsHit           = false;
     AttackPhaseDone = false;
     AttackType      = E_AttackType.None;
 }
Beispiel #6
0
    public override AnimAttackData GetFirstAttackAnim(E_WeaponType weapon, E_AttackType attackType)
    {
        if (attackType == E_AttackType.Fatality)
        {
            return(AttackKnockdown);
        }

        return(null);
    }
Beispiel #7
0
    public override AnimAttackData GetFirstAttackAnim(E_WeaponType weapom, E_AttackType attackType)
    {
        if (attackType == E_AttackType.Counter)
        {
            return(AnimAttacksSwordCounter);
        }

        return(AnimAttacksSwordL);
    }
Beispiel #8
0
    public override void Activate()
    {
        base.Activate();

        CurrentAttacktype = E_AttackType.X;
        NumberOfAttacks   = UnityEngine.Random.Range(2, 4);


        DoAttackAction(Owner.BlackBoard.DesiredTarget); // first attack is aimed
    }
    public override AnimAttackData GetFirstAttackAnim(E_WeaponType weapom, E_AttackType attackType)
    {
        if (attackType == E_AttackType.X)
        {
            return(AnimAttacksSword1);
        }


        return(AnimAttacksSword2);
    }
Beispiel #10
0
    private AnimAttackData ProcessCombo(E_AttackType attackType)
    {
        if (attackType != E_AttackType.O && attackType != E_AttackType.X)
        {
            return(null);
        }
        ComboProgress.Add(attackType);

        for (int i = 0; i < SkillData.PlayerComboAttacks.Length; i++)
        {        // projedem vsechny attacky
            Combo combo = SkillData.PlayerComboAttacks[i];
            if (combo.SwordLevel > Game.Instance.SwordLevel)
            {
                continue;                                                // nema combo...
            }
            bool valid = ComboProgress.Count <= combo.ComboSteps.Length; //
            for (int ii = 0; ii < ComboProgress.Count && ii < combo.ComboSteps.Length; ii++)
            {
                if (ComboProgress[ii] != combo.ComboSteps[ii].AttackType || combo.ComboSteps[ii].ComboLevel > Game.Instance.ComboLevel[i])
                {                // combo nepokracuje timto stepem... nebo step neni available
                    valid = false;
                    break;
                }
            }
            if (valid)
            {
                combo.ComboSteps[ComboProgress.Count - 1].Data.LastAttackInCombo  = NextAttackIsAvailable(E_AttackType.X) == false && NextAttackIsAvailable(E_AttackType.O) == false;
                combo.ComboSteps[ComboProgress.Count - 1].Data.FirstAttackInCombo = false;
                combo.ComboSteps[ComboProgress.Count - 1].Data.ComboIndex         = i;
                combo.ComboSteps[ComboProgress.Count - 1].Data.FullCombo          = ComboProgress.Count == combo.ComboSteps.Length;
                combo.ComboSteps[ComboProgress.Count - 1].Data.ComboStep          = ComboProgress.Count;
                //GuiManager.Instance.ShowComboProgress(ComboProgress);
                return(combo.ComboSteps[ComboProgress.Count - 1].Data);
            }
        }

        ComboProgress.Clear();
        ComboProgress.Add(attackType);

        for (int i = 0; i < SkillData.PlayerComboAttacks.Length; i++)
        {        // projedem vsechny prvni stepy
            if (SkillData.PlayerComboAttacks[i].ComboSteps[0].AttackType == attackType)
            {
                SkillData.PlayerComboAttacks[i].ComboSteps[0].Data.FirstAttackInCombo = true;
                SkillData.PlayerComboAttacks[i].ComboSteps[0].Data.LastAttackInCombo  = false;
                SkillData.PlayerComboAttacks[i].ComboSteps[0].Data.ComboIndex         = i;
                SkillData.PlayerComboAttacks[i].ComboSteps[0].Data.FullCombo          = false;
                SkillData.PlayerComboAttacks[i].ComboSteps[0].Data.ComboStep          = 0;
                //GuiManager.Instance.ShowComboProgress(ComboProgress);
                return(SkillData.PlayerComboAttacks[i].ComboSteps[0].Data);
            }
        }
        Debug.LogError("Could not find any combo attack !!! Some shit happens");
        return(null);
    }
Beispiel #11
0
    void CreateOrderAttack(E_AttackType type)
    {
        AgentOrder order = AgentOrderFactory.Create(AgentOrder.E_OrderType.E_ATTACK);

        order.AttackType = type;
        //todo ... 移动方向或者正前方
        order.Direction = Transform.forward;
        //todo ... 攻击动画信息
        order.AnimAttackData = null;
        //todo ... 获取当前最佳攻击对象
        order.Target = null;
        //todo ... 根据条件添加
        Agent.BlackBoard.AddOrder(order);
    }
    public override AnimAttackData GetFirstAttackAnim(E_WeaponType weapon, E_AttackType attackType)
    {
        if (attackType == E_AttackType.X)
        {
            return(AnimAttackX);
        }
        else if (attackType == E_AttackType.O)
        {
            return(AnimAttackInjury);
        }
        else if (attackType == E_AttackType.Berserk)
        {
            return(AnimAttackBerserk);
        }

        return(null);
    }
Beispiel #13
0
    public override AnimAttackData GetFirstAttackAnim(E_WeaponType weapom, E_AttackType attackType)
    {
        if (attackType == E_AttackType.X)
        {
            return(AnimAttacksSwordL);
        }
        else if (attackType == E_AttackType.Fatality)
        {
            return(AnimAttacksAfterknockdown);
        }
        else if (attackType == E_AttackType.BossBash)
        {
            return(AnimAttacksBash);
        }

        return(AnimAttacksSwordS);
    }
Beispiel #14
0
    public override void Update()
    {
        if (Action.AttackPhaseDone == true && NumberOfAttacks > 0)
        {
            if (CurrentAttacktype == E_AttackType.X)
            {
                CurrentAttacktype = E_AttackType.O;
            }
            else
            {
                CurrentAttacktype = E_AttackType.X;
            }

            Owner.Sound.PlayPrepareAttack();

            DoAttackAction(null); //next attack is just forward
        }
    }
Beispiel #15
0
    private bool NextAttackIsAvailable(E_AttackType attackType)
    {
        if (attackType != E_AttackType.O && attackType != E_AttackType.X)
        {
            return(false);
        }

        if (ComboProgress.Count == 5) // ehmm. proste je jich ted sest, tak bacha na to...
        {
            return(false);
        }

        List <E_AttackType> progress = new List <E_AttackType>(ComboProgress);

        progress.Add(attackType);

        for (int i = 0; i < PlayerComboAttacks.Length; i++)
        {// projedem vsechny attacky
            Combo combo = PlayerComboAttacks[i];

            if (combo.SwordLevel > Game.Instance.SwordLevel)
            {
                continue;
            }

            bool valid = true;
            for (int ii = 0; ii < progress.Count; ii++)
            {
                if (progress[ii] != combo.ComboSteps[ii].AttackType || combo.ComboSteps[ii].ComboLevel > Game.Instance.ComboLevel[i])
                {
                    valid = false;
                    break;
                }
            }

            if (valid)
            {
                return(true);
            }
        }
        return(false);
    }
Beispiel #16
0
    private bool NextAttackIsAvailable(E_AttackType attackType)
    {
        if (attackType != E_AttackType.O && attackType != E_AttackType.X)
        {
            return(false);
        }

        if (comboProgress.Count == 5)
        {
            return(false);
        }

        List <E_AttackType> progress = new List <E_AttackType>(comboProgress);

        progress.Add(attackType);

        for (int i = 0; i < playerComboAttacks.Length; i++)
        {
            Combo combo = playerComboAttacks[i];

            if (combo.SwordLevel > swordLevel)
            {
                continue;
            }

            bool valid = true;
            for (int j = 0; j < progress.Count; j++)
            {
                if (progress[j] != combo.ComboSteps[j].AttackType || combo.ComboSteps[j].ComboLevel > comboLevels[i])
                {
                    valid = false;
                    break;
                }
            }

            if (valid)
            {
                return(true);
            }
        }
        return(false);
    }
Beispiel #17
0
    //  攻击动作
    private void CreateOrderAttack(E_AttackType type)
    {
        if (CouldBufferNewOrder() == false && CouldAddnewOrder() == false)
        {
            //  Debug.Log(Time.timeSinceLevelLoad + " attack order rejected, already buffered one ");
            return;
        }

        AgentOrder order = AgentOrderFactory.Create(AgentOrder.E_OrderType.E_ATTACK);

        order.Direction      = Owner.Transform.forward;
        order.AnimAttackData = ProcessCombo(type);

        //  查找最优的目标对象
        order.Target = GetBestTarget(false);

        if (CouldAddnewOrder())
        {
            //Debug.Log("order " + (order.Target != null ? order.Target.name : "no target") + " " + order.AnimAttackData.AnimName);
            Owner.BlackBoard.OrderAdd(order);
        }
        else
        {
            //Debug.Log("order to queue " + (order.Target != null ? order.Target.name : "no target") + " " + order.AnimAttackData.AnimName);
            bufferedOrders.Enqueue(order);
        }

        ActionAttack attack = ActionFactory.Create(ActionFactory.E_Type.E_ATTACK) as ActionAttack;

        attack.Data                  = order.AnimAttackData;
        attack.AttackDir             = Owner.Transform.forward;
        attack.Target                = order.Target;
        Owner.BlackBoard.WeaponState = E_WeaponState.Ready;

        //  currentAttackAction = attack;
        weaponStartTime = 0;
        GetComponent <AnimComponent>().HandleAction(attack);
    }
Beispiel #18
0
    // static string[] ComboNames = { "Raising Waves", "Half Moon", "Could Cutting", "Flaying Dragon", "Walking Death", "Shogun Death" };

    private AnimAttackData ProcessCombo(E_AttackType attackType)
    {
        if (attackType != E_AttackType.O && attackType != E_AttackType.X)
        {
            return(null);
        }

        ComboProgress.Add(attackType);

        for (int i = 0; i < PlayerComboAttacks.Length; i++)
        {// projedem vsechny attacky
            Combo combo = PlayerComboAttacks[i];

            if (combo.SwordLevel > Game.Instance.SwordLevel)
            {
                continue;                                                // nema combo...
            }
            bool valid = ComboProgress.Count <= combo.ComboSteps.Length; //
            for (int ii = 0; ii < ComboProgress.Count && ii < combo.ComboSteps.Length; ii++)
            {
                if (ComboProgress[ii] != combo.ComboSteps[ii].AttackType || combo.ComboSteps[ii].ComboLevel > Game.Instance.ComboLevel[i])
                {// combo nepokracuje timto stepem... nebo step neni available
                    valid = false;
                    break;
                }
            }

            if (valid)
            {
                combo.ComboSteps[ComboProgress.Count - 1].Data.LastAttackInCombo  = NextAttackIsAvailable(E_AttackType.X) == false && NextAttackIsAvailable(E_AttackType.O) == false;
                combo.ComboSteps[ComboProgress.Count - 1].Data.FirstAttackInCombo = false;
                combo.ComboSteps[ComboProgress.Count - 1].Data.ComboIndex         = i;
                combo.ComboSteps[ComboProgress.Count - 1].Data.FullCombo          = ComboProgress.Count == combo.ComboSteps.Length;
                combo.ComboSteps[ComboProgress.Count - 1].Data.ComboStep          = ComboProgress.Count;

                //if (ComboProgress.Count == 3)
                //FlurryrBinding.FlurryLogPerformedCombo(ComboNames[i]);

                GuiManager.Instance.ShowComboProgress(ComboProgress);
                return(combo.ComboSteps[ComboProgress.Count - 1].Data);
            }
        }

        // takze zadny uspech

        //pokud ale je nabuferovano,tak nezacinat nove combo ?


        //je treba zacit od zacatku
        ComboProgress.Clear();
        ComboProgress.Add(attackType);

        for (int i = 0; i < PlayerComboAttacks.Length; i++)
        {// projedem vsechny prvni stepy
            if (PlayerComboAttacks[i].ComboSteps[0].AttackType == attackType)
            {
                // Debug.Log(Time.timeSinceLevelLoad + " New combo " + i + " step " + ComboProgress.Count);
                PlayerComboAttacks[i].ComboSteps[0].Data.FirstAttackInCombo = true;
                PlayerComboAttacks[i].ComboSteps[0].Data.LastAttackInCombo  = false;
                PlayerComboAttacks[i].ComboSteps[0].Data.ComboIndex         = i;
                PlayerComboAttacks[i].ComboSteps[0].Data.FullCombo          = false;
                PlayerComboAttacks[i].ComboSteps[0].Data.ComboStep          = 0;

                GuiManager.Instance.ShowComboProgress(ComboProgress);
                return(PlayerComboAttacks[i].ComboSteps[0].Data);
            }
        }

        Debug.LogError("Could not find any combo attack !!! Some shit happens");

        return(null);
    }
Beispiel #19
0
    private AnimAttackData ProcessCombo(E_AttackType attackType)
    {
        if (attackType != E_AttackType.O && attackType != E_AttackType.X)
        {
            return(null);
        }

        comboProgress.Add(attackType);

        //  如果攻击方式与连招匹配,同时玩家的等级都达到要求(默认调成最高等级,都满足)
        for (int i = 0; i < playerComboAttacks.Length; i++)
        {
            Combo combo = playerComboAttacks[i];

            //  如果当前连招需要的剑的等级高于玩家的剑等级,直接跳过
            if (combo.SwordLevel > swordLevel)
            {
                continue;
            }

            bool valid = comboProgress.Count <= combo.ComboSteps.Length;
            for (int j = 0; j < comboProgress.Count && j < combo.ComboSteps.Length; j++)
            {
                if (comboProgress[j] != combo.ComboSteps[j].AttackType || combo.ComboSteps[j].ComboLevel > comboLevels[i])
                {
                    valid = false;
                    break;
                }
            }

            if (valid)
            {
                combo.ComboSteps[comboProgress.Count - 1].Data.LastAttackInCombo  = NextAttackIsAvailable(E_AttackType.X) == false && NextAttackIsAvailable(E_AttackType.O) == false;
                combo.ComboSteps[comboProgress.Count - 1].Data.FirstAttackInCombo = false;
                combo.ComboSteps[comboProgress.Count - 1].Data.ComboIndex         = i;
                combo.ComboSteps[comboProgress.Count - 1].Data.FullCombo          = comboProgress.Count == combo.ComboSteps.Length;
                combo.ComboSteps[comboProgress.Count - 1].Data.ComboStep          = comboProgress.Count;

                MainPanelCtrl.Instance.ComboProgressMessage(comboProgress);
                return(combo.ComboSteps[comboProgress.Count - 1].Data);
            }
        }

        //  如果不满足,将连招缓存清空,重新开始记录
        comboProgress.Clear();
        comboProgress.Add(attackType);

        for (int i = 0; i < playerComboAttacks.Length; i++)
        {
            if (playerComboAttacks[i].ComboSteps[0].AttackType == attackType)
            {
                // Debug.Log(Time.timeSinceLevelLoad + " New combo " + i + " step " + comboProgress.Count);
                playerComboAttacks[i].ComboSteps[0].Data.FirstAttackInCombo = true;
                playerComboAttacks[i].ComboSteps[0].Data.LastAttackInCombo  = false;
                playerComboAttacks[i].ComboSteps[0].Data.ComboIndex         = i;
                playerComboAttacks[i].ComboSteps[0].Data.FullCombo          = false;
                playerComboAttacks[i].ComboSteps[0].Data.ComboStep          = 0;

                MainPanelCtrl.Instance.ComboProgressMessage(comboProgress);
                return(playerComboAttacks[i].ComboSteps[0].Data);
            }
        }

        Debug.LogError("Could not find any combo attack !!! Some shit happens");

        return(null);
    }
 public override AnimAttackData GetChainedAttackAnim(AnimAttackData parent, E_AttackType attackType)
 {
     return(null);
 }
Beispiel #21
0
 public override AnimAttackData GetFirstAttackAnim(E_WeaponType weapom, E_AttackType attackType)
 {
     return(AnimAttacksSwordL);
 }
Beispiel #22
0
 public abstract AnimAttackData GetChainedAttackAnim(AnimAttackData parent, E_AttackType attackType);
Beispiel #23
0
    public void OrderAdd(AgentOrder order)
    {
        //  Debug.Log(Time.timeSinceLevelLoad + " order arrived " + order.Type);

        if (IsOrderAddPossible(order.Type))
        {
            Owner.WorldState.SetWSProperty(E_PropKey.E_ORDER, order.Type);

            switch (order.Type)
            {
            case AgentOrder.E_OrderType.E_STOPMOVE:
                Owner.WorldState.SetWSProperty(E_PropKey.E_AT_TARGET_POS, true);
                DesiredPosition = Owner.Position;
                break;

            case AgentOrder.E_OrderType.E_GOTO:
                Owner.WorldState.SetWSProperty(E_PropKey.E_AT_TARGET_POS, false);
                DesiredPosition   = order.Position;
                DesiredDirection  = order.Direction;
                MoveSpeedModifier = order.MoveSpeedModifier;
                break;

            case AgentOrder.E_OrderType.E_DODGE:
                DesiredDirection = order.Direction;
                //  Debug.Log(Time.timeSinceLevelLoad + " order arrived " + order.Type);
                break;

            case AgentOrder.E_OrderType.E_USE:
                Owner.WorldState.SetWSProperty(E_PropKey.E_USE_WORLD_OBJECT, true);

                if ((order.Position - Owner.Position).sqrMagnitude <= 1)
                {
                    Owner.WorldState.SetWSProperty(E_PropKey.E_AT_TARGET_POS, true);
                }
                else
                {
                    Owner.WorldState.SetWSProperty(E_PropKey.E_AT_TARGET_POS, false);
                }
                DesiredPosition   = order.Position;
                InteractionObject = order.InteractionObject;
                Interaction       = order.Interaction;
                break;

            case AgentOrder.E_OrderType.E_ATTACK:
                if (order.Target == null || (order.Target.Position - Owner.Position).magnitude <= (WeaponRange + 0.2f))
                {
                    Owner.WorldState.SetWSProperty(E_PropKey.E_IN_WEAPONS_RANGE, true);
                }
                else
                {
                    Owner.WorldState.SetWSProperty(E_PropKey.E_IN_WEAPONS_RANGE, false);
                }

                DesiredAttackType  = order.AttackType;
                DesiredTarget      = order.Target;
                DesiredDirection   = order.Direction;
                DesiredAttackPhase = order.AnimAttackData;
                break;
            }

            // Debug.Log(Time.timeSinceLevelLoad + " order arrived " + order.Type);
        }
        else if (order.Type == AgentOrder.E_OrderType.E_ATTACK)
        {
            // Debug.Log(Time.timeSinceLevelLoad +  " " +order.Type + " is nto allowed because " + currentOrder);
        }
        AgentOrderFactory.Return(order);
    }
Beispiel #24
0
 public abstract AnimAttackData GetFirstAttackAnim(E_WeaponType weapon, E_AttackType attackType);