コード例 #1
0
    protected override void Initialize(AgentAction action)
    {
        base.Initialize(action);

        Action = action as AgentActionInjury;

        if (PlayAnimTime < Time.timeSinceLevelLoad)
        {
            // play owner anims
            string animName = Owner.AnimSet.GetInjuryAnim();

            PlayAnimTime = Time.timeSinceLevelLoad + Animation[animName].length * 0.35f;
            CrossFade(animName, 0.25f, PlayMode.StopSameLayer);

            EndOfStateTime = Animation[animName].length + Time.timeSinceLevelLoad;
        }
        else
        {
            EndOfStateTime = 0.2f + Time.timeSinceLevelLoad;
        }

        Owner.BlackBoard.MotionType = E_MotionType.None;

        MoveTime        = Random.Range(0.05f, 0.09f);
        CurrentMoveTime = 0;

        Impulse = Action.Impulse;

        PositionOK = Impulse == Vector3.zero;

        Owner.BlackBoard.MotionType = E_MotionType.Injury;
    }
コード例 #2
0
    void InitializeNext(AgentAction action)
    {
        if (CurrentPhase + 1 == MaxPhases)
        {/// no more phases
            action.SetFailed();
            return;
        }

        if (Action != null)
        {
            Action.SetSuccess();
        }

        SetFinished(false); // just for sure

        CurrentPhase++;

        Action = action as AgentActionInjury;

        // play owner anims
        string animName = Owner.AnimSet.GetInjuryPhaseAnim(CurrentPhase);

        CrossFade(animName, 0.1f);
        //end of state
        EndOfStateTime = AnimEngine[animName].length + Time.timeSinceLevelLoad;

        Owner.BlackBoard.MotionType = E_MotionType.None;
    }
コード例 #3
0
    protected override void Initialize(AgentAction action)
    {
        base.Initialize(action);
        AgentActionInjury injuryAction = Owner.BlackBoard.curAction as AgentActionInjury;
        string            animName     = Owner.AnimSet.GetInjuryAnim(injuryAction.fromWeapon, injuryAction.damageType);

        CrossFade(animName, 0.1f);
        _endOfStateTime             = Owner.AnimEngine[animName].length + Time.timeSinceLevelLoad;
        Owner.BlackBoard.motionType = MotionType.NONE;
        _moveTime        = Owner.AnimEngine[animName].length * 0.5f;
        _currentMoveTime = 0;

        if (injuryAction.attacker != null && Owner.isPlayer == false)
        {
            Vector3 dir = injuryAction.attacker.Position - Owner.Transform.position;
            dir.Normalize();
            _finalRotation.SetLookRotation(dir);
            _startRotation    = Owner.Transform.rotation;
            _rotationProgress = 0;
            _rotationOk       = false;
        }
        else
        {
            _rotationOk = true;
        }

        _impuls     = injuryAction.impuls * 10;
        _positionOK = _impuls == Vector3.zero;
        Owner.BlackBoard.motionType = MotionType.INJURY;
    }
コード例 #4
0
ファイル: AnimState.cs プロジェクト: huokele/shadow-gun
    protected void PlayInjuryAnimation(AgentActionInjury action)
    {
        if (PlayInjuryTime > Time.timeSinceLevelLoad)
        {
            action.SetSuccess();
            return;
        }

        string animName = Owner.AnimSet.GetInjuryAnim();

        Animation[animName].blendMode = AnimationBlendMode.Additive;
        Animation[animName].layer     = 0;

        //FIX IT !!!!!!

        /*if (Owner.BlackBoard.MotionType == E_MotionType.None)
         * {
         * Animation[animName].RemoveMixingTransform(Stomach);
         * }
         * else
         * {
         * Animation[animName].AddMixingTransform(Stomach);
         * }*/

        Blend(animName, 1, 0.1f);

        PlayInjuryTime = Time.timeSinceLevelLoad + Animation[animName].length * 0.35f;

        action.SetSuccess();
    }
コード例 #5
0
    public override void Reset()
    {
        Action.SetSuccess();
        Action = null;

        base.Reset();
    }
コード例 #6
0
    protected override AgentAction MakeAgentAction()
    {
        AgentActionInjury agentAction = AgentActionFactory.Get(AgentActionType.INJURY, Owner) as AgentActionInjury;

        agentAction.damageType = Owner.BlackBoard.damageType;
        agentAction.fromWeapon = Owner.BlackBoard.attackerWeapon;
        agentAction.attacker   = Owner.BlackBoard.attacker;
        agentAction.impuls     = Owner.BlackBoard.impuls;
        return(agentAction);
    }
コード例 #7
0
    override public void OnDeactivate()
    {
        //  Time.timeScale = 1;

        Action.SetSuccess();
        Action = null;

        Owner.BlackBoard.MotionType = E_MotionType.None;

        base.OnDeactivate();
    }
コード例 #8
0
    public override void OnDeactivate()
    {
        Owner.BlackBoard.MotionType = E_MotionType.None;
        Owner.BlackBoard.MoveDir    = Vector3.zero;
        Owner.BlackBoard.Speed      = 0;

        Action.SetSuccess();
        Action = null;

        base.OnDeactivate();
    }
コード例 #9
0
ファイル: GOAPActionInjury.cs プロジェクト: cuongdv/wushi2
    private void SendAction()
    {
        Action            = AgentActionFactory.Create(AgentActionFactory.E_Type.E_INJURY) as AgentActionInjury;
        Action.DamageType = Owner.BlackBoard.DamageType;
        Action.FromWeapon = Owner.BlackBoard.AttackerWeapon;
        Action.Attacker   = Owner.BlackBoard.Attacker;
        Action.Impuls     = Owner.BlackBoard.Impuls;

        Owner.BlackBoard.ActionAdd(Action);

        Owner.WorldState.SetWSProperty(E_PropKey.E_EVENT, E_EventTypes.ImInPain);
    }
コード例 #10
0
    public override void Deactivate()
    {
        Owner.BlackBoard.Invulnerable = false;
        Action       = null;
        ActionAttack = null;
        base.Deactivate();

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

        if (prop == null || prop.GetEvent() != E_EventTypes.Hit)
        {
            return;
        }
        // if there is some hit, clear it !!
        Owner.WorldState.SetWSProperty(E_PropKey.E_EVENT, E_EventTypes.None);
    }
コード例 #11
0
    private void SendAction()
    {
        Count++;

        Action            = AgentActionFactory.Create(AgentActionFactory.E_Type.E_INJURY) as AgentActionInjury;
        Action.DamageType = Owner.BlackBoard.DamageType;
        Action.FromWeapon = Owner.BlackBoard.AttackerWeapon;
        Action.Attacker   = Owner.BlackBoard.Attacker;
        Action.Impuls     = Owner.BlackBoard.Impuls;

        Owner.BlackBoard.ActionAdd(Action);

        Owner.WorldState.SetWSProperty(E_PropKey.E_EVENT, E_EventTypes.ImInPain);

        //UnityEngine.Debug.Log(this.ToString() + " sending injury number " + Count);
    }
コード例 #12
0
    protected override void Initialize(AgentAction action)
    {
        base.Initialize(action);

        CurrentPhase = 0;

        Action = action as AgentActionInjury;

        // play owner anims
        string animName = Owner.AnimSet.GetInjuryPhaseAnim(CurrentPhase);

        CrossFade(animName, 0.1f);
        //end of state
        EndOfStateTime = AnimEngine[animName].length + Time.timeSinceLevelLoad;

        Owner.BlackBoard.MotionType = E_MotionType.None;
    }
コード例 #13
0
ファイル: GOAPActionInjury.cs プロジェクト: cuongdv/wushi2
    public override void Deactivate()
    {
        Action = null;
        base.Deactivate();

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

        if (prop == null || prop.GetEvent() != E_EventTypes.ImInPain)
        {
            return;
        }

        if (WorldStateTime == prop.Time)
        {
            Owner.WorldState.SetWSProperty(E_PropKey.E_EVENT, E_EventTypes.None);
        }
    }
コード例 #14
0
ファイル: GOAPActionInjury.cs プロジェクト: cuongdv/wushi2
    public override void Activate()
    {
        base.Activate();

        Action        = null;
        Interruptible = false;

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

        if (prop == null || prop.GetEvent() != E_EventTypes.Hit)
        {
            return;
        }

        WorldStateTime = prop.Time;

        SendAction();
    }
コード例 #15
0
    protected override void Initialize(AgentAction action)
    {
        base.Initialize(action);

        Action = action as AgentActionInjury;

        // play owner anims
        string animName = Owner.AnimSet.GetInjuryAnim(Action.FromWeapon, Action.DamageType);

        CrossFade(animName, 0.1f);
        //end of state
        EndOfStateTime = AnimEngine[animName].length + Time.timeSinceLevelLoad;

        // Debug.Log(Action.AnimName + " " + EndOfStateTime );
        Owner.BlackBoard.MotionType = E_MotionType.None;

        MoveTime        = AnimEngine[animName].length * 0.5f;
        CurrentMoveTime = 0;

        if (Action.Attacker != null && Owner.IsPlayer == false)
        {
            Vector3 dir = Action.Attacker.Position - Transform.position;
            dir.Normalize();
            FinalRotation.SetLookRotation(dir);
            StartRotation    = Transform.rotation;
            RotationProgress = 0;
            RotationOk       = false;
        }
        else
        {
            RotationOk = true;
        }

        Impuls = Action.Impuls * 10;

        PositionOK = Impuls == Vector3.zero;

        // Debug.Log("recieve injury : " + animName + " end time " + EndOfStateTime + " start time "  + Time.timeSinceLevelLoad);

        Owner.BlackBoard.MotionType = E_MotionType.Injury;
    }
コード例 #16
0
    public static 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.Idle:
                a = new AgentActionIdle();
                break;

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

            case E_Type.Sprint:
                a = new AgentActionSprint();
                break;

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

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

            case E_Type.Melee:
                a = new AgentActionMelee();
                break;

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

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

            case E_Type.WeaponChange:
                a = new AgentActionWeaponChange();
                break;

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

            case E_Type.Use:
                a = new AgentActionUse();
                break;

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

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

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

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

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

            case E_Type.CoverEnter:
                a = new AgentActionCoverEnter();
                break;

            case E_Type.CoverMove:
                a = new AgentActionCoverMove();
                break;

            case E_Type.CoverFire:
                a = new AgentActionCoverFire();
                break;

            case E_Type.CoverFireCancel:
                a = new AgentActionCoverFireCancel();
                break;

            case E_Type.CoverLeave:
                a = new AgentActionCoverLeave();
                break;

            case E_Type.Reload:
                a = new AgentActionReload();
                break;

            case E_Type.UseItem:
                a = new AgentActionUseItem();
                break;

            case E_Type.ConstructGadget:
                a = new AgentActionConstructGadget();
                break;

            case E_Type.TeamCommand:
                a = new AgentActionTeamCommand();
                break;

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

        // DEBUG !!!!!!
        //	m_ActionsInAction.Add(a);
        return(a);
    }
コード例 #17
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);
    }