Exemple #1
0
    private void DoAction()
    {
        Action = null;

        if (Owner.BlackBoard.DesiredTarget == null)
        {
            return;
        }

        Action = AgentActionFactory.Create(AgentActionFactory.E_Type.E_BLOCK) as AgentActionBlock;

        Action.Attacker = Owner.BlackBoard.DesiredTarget;
        Action.Time     = 3.0f;

        Owner.BlackBoard.ActionAdd(Action);

        WorldStateProp prop = Owner.WorldState.GetWSProperty(E_PropKey.E_IN_DODGE);

        if (prop == null || prop.GetBool() == true)
        {
            return;
        }

        //WorldStateTime = prop.Time;


        //UnityEngine.Debug.Log(this.ToString() + "Send new roll action to pos " + Action.Direction.ToString());
    }
Exemple #2
0
    protected override AgentAction MakeAgentAction()
    {
        AgentActionBlock agentAction = AgentActionFactory.Get(AgentActionType.BLOCK, Owner) as AgentActionBlock;

        agentAction.attacker = Owner.BlackBoard.desiredTarget;
        agentAction.time     = 3.0f;
        return(agentAction);
    }
Exemple #3
0
    public override void Deactivate()
    {
        Owner.WorldState.SetWSProperty(E_PropKey.E_IN_BLOCK, false);

        //AgentActionFactory.Return(Action);
        Action = null;

        base.Deactivate();
    }
Exemple #4
0
    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();
    }
Exemple #5
0
    protected override void Initialize(AgentAction action)
    {
        base.Initialize(action);


        //Debug.Log(Time.timeSinceLevelLoad + Owner.name + "Block init");
        ActionBlock = action as AgentActionBlock;

        string animName = Owner.AnimSet.GetBlockAnim(E_BlockState.Start, Owner.BlackBoard.WeaponSelected);

        StartRotation = Transform.rotation;
        StartPosition = Transform.position;

        Vector3 dir   = ActionBlock.Attacker.Position - Transform.position;
        float   angle = 0;

        if (dir.sqrMagnitude > 0.1f * 0.1f)
        {
            dir.Normalize();
            angle = Vector3.Angle(Transform.forward, dir);
        }
        else
        {
            dir = Transform.forward;
        }


        FinalRotation.SetLookRotation(dir);
        RotationTime = angle / 500.0f;
        MoveTime     = 0;

        RotationOk = RotationTime == 0;
        PositionOK = MoveTime == 0;

        CurrentRotationTime = 0;
        CurrentMoveTime     = 0;

        CrossFade(animName, 0.05f);

        EndOfStateTime = Time.timeSinceLevelLoad + AnimEngine[animName].length * 0.9f;
        BlockEndTime   = Time.timeSinceLevelLoad + ActionBlock.Time;

        State = E_State.E_START;
    }
Exemple #6
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);
    }