Esempio n. 1
0
    override public bool HandleNewAction(AgentAction action)
    {
        if (action is AgentActioCombatMove)
        {
            if (Action != null)
            {
                Action.SetSuccess();
            }

            SetFinished(false); // just for sure, if we already finish in same tick

            Initialize(action);

            return(true);
        }

        if (action is AgentActionIdle)
        {
            action.SetSuccess();
            SetFinished(true);
        }

        if (action is AgentActionWeaponShow)
        {
            action.SetSuccess();

            //Owner.ShowWeapon((action as AgentActionWeaponShow).Show, 0);

            UpdateMoveType();
            return(true);
        }
        return(false);
    }
Esempio n. 2
0
    public override bool HandleNewAction(AgentAction _action)
    {
        if (_action is AgentActionMove)
        {
            if (null != Action)
            {
                Action.SetSuccess();
            }
            SetFinished(false);

            Initialize(_action);
            return(true);
        }

        if (_action is AgentActionWeaponShow)
        {
            _action.SetSuccess();
            //todo: play Animation
            PlayAnim(GetMotionType());
            return(true);
        }

        if (_action is AgentActionIdle)
        {
            _action.SetSuccess();
            SetFinished(true);
        }
        return(false);
    }
Esempio n. 3
0
 public override void OnDeactivate()
 {
     Animation[AnimName].layer = 0;
     Action.SetSuccess();
     Action = null;
     base.OnDeactivate();
 }
Esempio n. 4
0
    public override bool HandleNewAction(AgentAction action)
    {
        if (action is AgentActionGoTo)
        {
            if (Action != null)
            {
                Action.SetSuccess();
            }

            SetFinished(false);             // just for sure, if we already finish in same tick

            Initialize(action);

            return(true);
        }

        if (action is AgentActionReload)
        {
            string s = Owner.AnimSet.GetWeaponAnim(E_WeaponAction.Reload);
            Animation[s].layer     = 2;
            Animation[s].blendMode = AnimationBlendMode.Additive;
            Blend(s, 0.1f);

            action.SetSuccess();

            return(true);
        }

        return(false);
    }
Esempio n. 5
0
    public override bool HandleNewAction(AgentAction action)
    {
        if (action as AgentActionKnockdown != null)
        {
            Debug.LogError("obsolete AgentActionKnockdown arrived");
            action.SetFailed();
            return(true);
        }
        else if (action as AgentActionInjury != null)
        {
            action.SetSuccess();
            return(true);
        }

        /*else if (action as AgentActionDeath != null)
         * {
         * ActionDeath = action as AgentActionDeath;
         * //if (Owner.debugAnims == true) Debug.Log(Time.timeSinceLevelLoad + " " + this.ToString() + " Handle new action " + action.ToString());
         *
         *
         * InitializeDeath();
         *
         * return true;
         * }*/

        return(false);
    }
Esempio n. 6
0
    override public bool HandleNewAction(AgentAction action)
    {
        if (action is AgentActionGoTo)
        {
            if (Action != null)
            {
                Action.SetSuccess();
            }

            SetFinished(false); // just for sure, if we already finish in same tick

            Initialize(action);

            return(true);
        }

        if (action is AgentActionWeaponShow)
        {
            action.SetSuccess();

            //Owner.ShowWeapon((action as AgentActionWeaponShow).Show, 0);

            PlayAnim(GetMotionType());
            return(true);
        }
        return(false);
    }
Esempio n. 7
0
    public override void OnDeactivate()
    {
        if (WeaponAction != null)
        {
            WeaponAction.SetSuccess();
            WeaponAction = null;
        }

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

        base.OnDeactivate();
    }
Esempio n. 8
0
 public override void Update()
 {
     if (WeaponAction != null && TimeToFinishWeaponAction < Time.timeSinceLevelLoad)
     {
         WeaponAction.SetSuccess();
         WeaponAction = null;
         PlayIdleAnim();
     }
 }
Esempio n. 9
0
 override public void Update()
 {
     if (WeaponAction != null && TimeToFinishWeaponAction < Time.timeSinceLevelLoad)
     {
         WeaponAction.SetSuccess();
         WeaponAction = null;
         CrossFade(Owner.AnimSet.GetIdleAnim(Owner.BlackBoard.WeaponSelected, Owner.BlackBoard.WeaponState), 0.2f);
     }
 }
Esempio n. 10
0
    override public void OnDeactivate()
    {
        //  Time.timeScale = 1;
        LookAtTarget = false;
        Action.SetSuccess();
        Action = null;
        base.OnDeactivate();

        //Debug.Log(this.ToString() + " Deactivate");
    }
Esempio n. 11
0
    public override bool HandleNewAction(AgentAction action)
    {
        if (action is AgentActionCoverMove)
        {
            if (Action != null)
            {
                Action.SetSuccess();
            }

            SetFinished(false);             // just for sure, if we already finish in same tick

            Initialize(action);

            return(true);
        }

        if (action is AgentActionInjury)
        {
            PlayInjuryAnimation(action as AgentActionInjury);
            return(true);
        }

        if (action is AgentActionIdle)
        {
            action.SetSuccess();

            SetFinished(true);
        }

        if (action is AgentActionKnockdown)
        {
            action.SetSuccess();

            return(true);
        }

        return(false);
    }
Esempio n. 12
0
    protected override void Initialize(AgentAction action)
    {
        base.Initialize(action);

        Owner.BlackBoard.MotionType = E_MotionType.None;
        Owner.BlackBoard.MoveDir    = Vector3.zero;
        Owner.BlackBoard.Speed      = 0;

        if (WeaponAction == null)
        {
            PlayIdleAnim(InstantBlend);
        }

        InstantBlend = false;

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

        if (Owner.BlackBoard.AimAnimationsEnabled && Owner.IsInCover == false)
        {
            AnimNameUp   = Owner.AnimSet.GetAimAnim(E_AimDirection.Up, E_CoverPose.None, E_CoverDirection.Unknown);
            AnimNameDown = Owner.AnimSet.GetAimAnim(E_AimDirection.Down, E_CoverPose.None, E_CoverDirection.Unknown);

            Animation[AnimNameUp].wrapMode   = WrapMode.ClampForever;
            Animation[AnimNameDown].wrapMode = WrapMode.ClampForever;

            Animation[AnimNameUp].blendMode = AnimationBlendMode.Additive;
            Animation[AnimNameUp].layer     = 1;

            Animation[AnimNameDown].blendMode = AnimationBlendMode.Additive;
            Animation[AnimNameDown].layer     = 1;

            //Debug.Log("anim up " + AnimNameUp + " down " + AnimNameDown);

            UpdateBlendValues();

            Animation[AnimNameUp].time   = 0.0333f;
            Animation[AnimNameDown].time = 0.0333f;

            Animation[AnimNameUp].weight   = BlendUp;
            Animation[AnimNameDown].weight = BlendDown;

            Animation.Blend(AnimNameUp, BlendUp, 0);
            Animation.Blend(AnimNameDown, BlendDown, 0);
        }
    }
Esempio n. 13
0
    public override bool HandleNewAction(AgentAction action)
    {
        if (action is AgentActionCoverFire)
        {
            Debug.LogError(ToString() + ": Second action is not allowed");
            action.SetFailed();
            return(true);
        }

        if (action is AgentActionCoverFireCancel)
        {
            ActionCancel = action as AgentActionCoverFireCancel;
            StartEnd();
            return(true);
        }

        if (action is AgentActionInjury)
        {
            PlayInjuryAnimation(action as AgentActionInjury);
            return(true);
        }

        if (action is AgentActionAttack)
        {
            string s = Owner.AnimSet.GetWeaponAnim(E_WeaponAction.Fire);

            Animation[s].blendMode = AnimationBlendMode.Additive;
            Animation[s].layer     = 2;

            if (Animation.IsPlaying(s))
            {
                Animation[s].time = 0;
            }
            else
            {
                Blend(s, 0.05f);
            }

            action.SetSuccess();
            return(true);
        }

        return(false);
    }
Esempio n. 14
0
    public override bool HandleNewAction(AgentAction action)
    {
        if (action is AgentActionCoverEnter)
        {
            if (Action != null)
            {
                Debug.LogError(ToString() + ": Second action is not allowed");
                action.SetFailed();
                return(true);
            }

            Initialize(action);

            return(true);
        }
        else if (action is AgentActionKnockdown)
        {
            action.SetSuccess();

            return(true);
        }

        return(false);
    }
Esempio n. 15
0
    public override bool HandleNewAction(AgentAction action)
    {
        if (action is AgentActionMove)
        {
            if (Action != null)
            {
                Action.SetSuccess();
            }

            SetFinished(false);             // just for sure, if we already finish in same tick

            Initialize(action);

            return(true);
        }

        if (action is AgentActionIdle)
        {
            action.SetSuccess();

            SetFinished(true);

            return(true);
        }
        else if (action is AgentActionAttack)
        {
            string s = Owner.AnimSet.GetWeaponAnim(E_WeaponAction.Fire);
            Animation[s].blendMode = AnimationBlendMode.Additive;

            if (Animation.IsPlaying(s))
            {
                Animation[s].time = 0;
            }
            else
            {
                Animation.Blend(s, 1, 0.1f);
            }

            action.SetSuccess();

            return(true);
        }
        else if (action is AgentActionInjury)
        {
            PlayInjuryAnimation(action as AgentActionInjury);
            return(true);
        }
        else if (action is AgentActionReload)
        {
            string s = Owner.AnimSet.GetWeaponAnim(E_WeaponAction.Reload);

            AnimationState State = Animation[s];
            if (null != State)
            {
                State.layer     = 2;
                State.blendMode = AnimationBlendMode.Blend;

                // What the magic constant 0.3f is good for? Is it here to cause the weapon to be ready little bit sooner
                // before the animation ends? Why?
                TimeToFinishWeaponAction = Time.timeSinceLevelLoad + State.length - 0.3f;
                Blend(s, 0.25f);
            }
            else
            {
                // TODO: It use to happen (not very often) that the state is NULL. This for example happens when s
                // is set to "ReloadPlasma". The plasma weapon does not have any reload. The question is what causes the bug?
                // A cheated client? Or a latency on the network? Another question is what to do in such case?
                // To fail an action sounds like a correct solution.


                action.SetFailed();
                return(true);
            }

            action.SetSuccess();
            return(true);
        }

        return(false);
    }
 public override void OnDeactivate()
 {
     Action.SetSuccess();
     Action = null;
     base.OnDeactivate();
 }
Esempio n. 17
0
    public override bool HandleNewAction(AgentAction action)
    {
        //if (m_Human.PlayerProperty != null)
        //if(Owner.debugAnims) Debug.Log(Time.timeSinceLevelLoad + " " + this.ToString() + " - action " + action.ToString());
        if (action is AgentActionIdle)
        {
            action.SetFailed();
            return(true);
        }
        else if (action is AgentActionAttack)
        {
            if (null != Owner.AnimSet)
            {
                string s = Owner.AnimSet.GetWeaponAnim(E_WeaponAction.Fire);

                if (null != s)
                {
                    AnimationState state = Animation[s];

                    if (null != state)
                    {
                        TimeToFinishWeaponAction = Time.timeSinceLevelLoad + state.length * 0.5f;

                        state.layer     = 2;
                        state.blendMode = AnimationBlendMode.Additive;

                        if (Animation.IsPlaying(s))
                        {
                            //Debug.Log(Time.timeSinceLevelLoad + " " + s + " rewind " + Animation[s].length + " " + Animation[s].time);
                            state.time = 0;
                        }
                        else
                        {
                            //Debug.Log(Time.timeSinceLevelLoad + " " + s + " fade " + Animation[s].length + " " + Animation[s].time);
                            Blend(s, 0.05f);
                        }
                    }
                }
            }

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

            WeaponAction = action;

            return(true);
        }
        else if (action is AgentActionInjury)
        {
            PlayInjuryAnimation(action as AgentActionInjury);
            return(true);
        }
        else if (action is AgentActionReload)
        {
            if (null != Owner.AnimSet)
            {
                string s = Owner.AnimSet.GetWeaponAnim(E_WeaponAction.Reload);

                if (null != s)
                {
                    AnimationState state = Animation[s];

                    if (null != state)
                    {
                        state.layer     = 2;
                        state.blendMode = AnimationBlendMode.Blend;

                        Blend(s, 0.2f);

                        TimeToFinishWeaponAction = Time.timeSinceLevelLoad + state.length - 0.3f;
                    }
                }

                action.SetSuccess();

                WeaponAction = action;

                //			PrevBlendUp *= 0.25f;		//this is to minimize the quick blend to aim after reload
                //			PrevBlendDown *= 0.25f;
            }

            return(true);
        }
        else if (action is AgentActionRotate)
        {
            RotateAction = action as AgentActionRotate;

            if (null != Owner.AnimSet)
            {
                string s = Owner.AnimSet.GetRotateAnim(RotateAction.Rotation);

                if (s != null && Animation.IsPlaying(s) == false)
                {
                    /*				if ( Animation[s] == null )
                     * {
                     *      Debug.Log ("Animation.Length=" + Animation.GetClipCount() + ", agent=" + Owner.name);
                     *
                     *      foreach ( AnimationClip clip in Animation )
                     *              Debug.Log ("clip=" + clip.name );
                     * }
                     */
                    AnimationState state = Animation[s];

                    if (null != state)
                    {
                        state.blendMode = AnimationBlendMode.Additive;

                        state.layer = 1;

                        TimeToFinishRotateAction = Time.timeSinceLevelLoad + state.length + 0.3f;

                        Blend(s, 0.1f);
                    }
                }
            }
        }
        return(false);
    }