コード例 #1
0
ファイル: AnimStateBlocking.cs プロジェクト: cuongdv/wushi2
    override public bool HandleNewAction(AgentAction action)
    {
        if (action as AgentActionBlock != null)
        {
            Debug.LogError("obsolete AgentActionBlock arrived");
            action.SetFailed();
            return(true);
        }
        if (action as AgentActionDamageBlocked != null)
        {
            ActionDamageBlocked = action as AgentActionDamageBlocked;
            //if (Owner.debugAnims == true) Debug.Log(Time.timeSinceLevelLoad + " Handle new action " + action.ToString());

            if (ActionDamageBlocked.BreakBlock == true)
            {
                InitializeBlockFailed();
            }
            else
            {
                InitializeBlockSuccess();
            }

            return(true);
        }

        return(false);
    }
コード例 #2
0
ファイル: AnimStateBlocking.cs プロジェクト: cuongdv/wushi2
    override public void OnDeactivate()
    {
        //  Time.timeScale = 1.0f;
        if (ActionDamageBlocked != null)
        {
            ActionDamageBlocked.SetSuccess();
        }

        ActionDamageBlocked = null;

        ActionBlock.SetSuccess();
        ActionBlock = null;

        Owner.BlackBoard.MotionType = E_MotionType.None;

        base.OnDeactivate();
    }
コード例 #3
0
ファイル: GOAPActionBlock.cs プロジェクト: cuongdv/wushi2
    public override void Update()
    {
        E_EventTypes eventType = Owner.WorldState.GetWSProperty(E_PropKey.E_EVENT).GetEvent();

        if (eventType == E_EventTypes.HitBlocked)
        {
            ActionInjuryBlocked                = AgentActionFactory.Create(AgentActionFactory.E_Type.E_DAMAGE_BLOCKED) as AgentActionDamageBlocked;
            ActionInjuryBlocked.Attacker       = Owner.BlackBoard.Attacker;
            ActionInjuryBlocked.AttackerWeapon = Owner.BlackBoard.AttackerWeapon;
            ActionInjuryBlocked.BreakBlock     = Owner.BlackBoard.DamageType == E_DamageType.BreakBlock;


            Owner.BlackBoard.ActionAdd(ActionInjuryBlocked);
            Owner.WorldState.SetWSProperty(E_PropKey.E_EVENT, E_EventTypes.None);
        }

        if (ActionInjuryBlocked != null && ActionInjuryBlocked.IsActive() == false)
        {
            //AgentActionFactory.Return(ActionInjuryBlocked);
            ActionInjuryBlocked = null;
        }
    }
コード例 #4
0
    static public AgentAction Create(E_Type type)
    {
        int index = (int)type;

        AgentAction a;

        if (m_UnusedActions[index].Count > 0)
        {
            a = m_UnusedActions[index].Dequeue();
        }
        else
        {
            switch (type)
            {
            case E_Type.E_IDLE:
                a = new AgentActionIdle();
                break;

            case E_Type.E_MOVE:
                a = new AgentActionMove();
                break;

            case E_Type.E_GOTO:
                a = new AgentActionGoTo();
                break;

            case E_Type.E_COMBAT_MOVE:
                a = new AgentActioCombatMove();
                break;

            case E_Type.E_ATTACK:
                a = new AgentActionAttack();
                break;

            case E_Type.E_ATTACK_ROLL:
                a = new AgentActionAttackRoll();
                break;

            case E_Type.E_ATTACK_WHIRL:
                a = new AgentActionAttackWhirl();
                break;

            case E_Type.E_INJURY:
                a = new AgentActionInjury();
                break;

            case E_Type.E_DAMAGE_BLOCKED:
                a = new AgentActionDamageBlocked();
                break;

            case E_Type.E_BLOCK:
                a = new AgentActionBlock();
                break;

            case E_Type.E_ROLL:
                a = new AgentActionRoll();
                break;

            case E_Type.E_INCOMMING_ATTACK:
                a = new AgentActionIncommingAttack();
                break;

            case E_Type.E_WEAPON_SHOW:
                a = new AgentActionWeaponShow();
                break;

            case E_Type.Rotate:
                a = new AgentActionRotate();
                break;

            case E_Type.E_USE_LEVER:
                a = new AgentActionUseLever();
                break;

            case E_Type.E_PLAY_ANIM:
                a = new AgentActionPlayAnim();
                break;

            case E_Type.E_PLAY_IDLE_ANIM:
                a = new AgentActionPlayIdleAnim();
                break;

            case E_Type.E_DEATH:
                a = new AgentActionDeath();
                break;

            case E_Type.E_KNOCKDOWN:
                a = new AgentActionKnockdown();
                break;

            case E_Type.Teleport:
                a = new AgentActionTeleport();
                break;

            default:
                Debug.LogError("no AgentAction to create");
                return(null);
            }
        }
        a.Reset();
        a.SetActive();

        // DEBUG !!!!!!
        m_ActionsInAction.Add(a);
        return(a);
    }
コード例 #5
0
ファイル: AnimStateBlocking.cs プロジェクト: cuongdv/wushi2
    override public void Update()
    {
        //if (m_Human.PlayerProperty != null)

        //Debug.Log(Time.timeSinceLevelLoad + " " + this.ToString() + " - update " + State.ToString() + " " + EndOfStateTime);
        UpdateFinalRotation();

        if (RotationOk == false)
        {
            CurrentRotationTime += Time.deltaTime;

            if (CurrentRotationTime >= RotationTime)
            {
                CurrentRotationTime = RotationTime;
                RotationOk          = true;
            }

            float      progress = CurrentRotationTime / RotationTime;
            Quaternion q        = Quaternion.Lerp(StartRotation, FinalRotation, progress);
            Owner.Transform.rotation = q;
        }

        if (PositionOK == false)
        {
            CurrentMoveTime += Time.deltaTime;
            if (CurrentMoveTime >= MoveTime)
            {
                CurrentMoveTime = MoveTime;
                PositionOK      = true;
            }

            float   progress = CurrentMoveTime / MoveTime;
            Vector3 finalPos = Mathfx.Sinerp(StartPosition, FinalPosition, progress);
            //MoveTo(finalPos);
            if (Move(finalPos - Transform.position) == false)
            {
                PositionOK = true;
            }
        }

        switch (State)
        {
        case E_State.E_START:
            if (EndOfStateTime <= Time.timeSinceLevelLoad)
            {
                InitializeBlockLoop();
            }
            break;

        case E_State.E_BLOCK:
            if (EndOfStateTime <= Time.timeSinceLevelLoad)
            {
                InitializeBlockEnd();
            }
            break;

        case E_State.E_BLOCK_HIT:
            if (EndOfStateTime <= Time.timeSinceLevelLoad)
            {
                if (Time.timeSinceLevelLoad < BlockEndTime)
                {
                    InitializeBlockLoop();
                }
                else
                {
                    InitializeBlockEnd();
                }

                if (ActionDamageBlocked != null)
                {
                    ActionDamageBlocked.SetSuccess();
                    ActionDamageBlocked = null;
                }
            }
            break;

        case E_State.E_END:
            if (EndOfStateTime <= Time.timeSinceLevelLoad)
            {
                Release();
            }
            break;
        }
    }