Esempio n. 1
0
    void InitActions()
    {
        MoveableObject lObject = new Creature("Lion");
        ActionRun      lRun    = new ActionRun();

        mActions.Add(lObject.Name, lRun.Execute);
    }
Esempio n. 2
0
    bool setRunDirection(ActionRun runAction, Direction newDirection)
    {
        Vector3 newDirectionVector = runAction.getDirectionVector(this.transform.position, newDirection);

        this.lastOffsetVector = this.calculateLineOffset(this.transform.position);
        if (newDirectionVector != Vector3.zero)
        {
            this.directionVector    = newDirectionVector;
            this.direction          = newDirection;
            this.runningStraight    = false;
            this.specialDirection   = runAction.getSpecialDirection();
            this.speedMultiplier    = runAction.getSpeedMultiplier(this.direction);
            this.maxSpeedMultiplier = runAction.getMaxSpeedMultiplier(this.direction);
            string newAnimation = runAction.getSpecialAnimation();
            if (newAnimation != null && newAnimation != "")
            {
                this.animator.SetTrigger(newAnimation);
            }
            return(true);
        }
        else
        {
            return(false);
        }
    }
    void OnSceneGUI()
    {
        ActionRun action = target as ActionRun;
        int       directions
            = (action.goForwardTowards == null ? 0x1 : 0)
              | (action.goLeftTowards == null ? 0x2 : 0)
              | (action.goRightTowards == null ? 0x4 : 0)
              | (action.goBackwardTowards == null ? 0x8 : 0);

        LevelBuilderCommon.DirectionalButtons(action, directions);
        if (action.safetyNet == null)
        {
            LevelBuilderCommon.SafetyNetButton(action);
        }
        LevelBuilderCommon.DeleteButton(action);
    }
Esempio n. 4
0
        public FighterStateMachine(
            Fighter fighter,
            float runSpeed
            ) : base()
        {
            Character.Anim.FighterAnimation  fighterAnimation  = fighter.GetComponent <Character.Anim.FighterAnimation> ();
            Character.Anim.MoveableAnimation moveableAnimation = fighter.GetComponent <Character.Anim.MoveableAnimation> ();
            CharacterController characterController            = fighter.GetComponent <CharacterController> ();

            mActionIdle   = new ActionIdle((int)eCharacterState.idle, moveableAnimation);
            mActionAttack = new ActionAttack((int)eCharacterState.attack, fighter);
            mActionRun    = new ActionRun((int)eCharacterState.run, moveableAnimation, fighter.transform, characterController, runSpeed);
            mActionDie    = new ActionDie((int)eCharacterState.die, fighterAnimation);

            addAction(mActionIdle);
            addAction(mActionAttack);
            addAction(mActionRun);
            addAction(mActionDie);

            startNewAction((int)eCharacterState.idle, false);
        }
Esempio n. 5
0
    bool parseAction(IAction action, Collider collider = null, bool trigger = false)
    {
        if (action is ActionTriggerRun)
        {
            ActionTriggerRun runActionTrigger = (ActionTriggerRun)action;
            return(this.setRunDirection(runActionTrigger, runActionTrigger.getDirection()));
        }
        else if (action is ActionRun)
        {
            ActionRun actionRun = action as ActionRun;
            if (trigger)
            {
                return(this.setRunDirection(actionRun, actionRun.GetTriggerDirection()));
            }
            if (this.wannaBeDirection != this.direction)
            {
                return(this.setRunDirection(actionRun, this.wannaBeDirection));
            }
        }
        else if (action is ActionSafetyNetForRun)
        {
            if (this.wannaBeDirection != this.direction)
            {
                return(((ActionSafetyNetForRun)action).EarlyMove(this.wannaBeDirection));
            }
        }
        else if (action is ActionTranslate)
        {
            ActionTranslate translateAction = (ActionTranslate)action;
            this.transform.Translate(translateAction.getTranslateVector(), Space.World);
            return(true);
        }

        else if (action is ActionDeath)
        {
            this.die(((ActionDeath)action).getType());
        }

        return(false);
    }
Esempio n. 6
0
 void InitActions()
 {
     MoveableObject lObject = new Creature("Lion");
     ActionRun lRun = new ActionRun();
     mActions.Add( lObject.Name, lRun.Execute );
 }
Esempio n. 7
0
    bool parseAction(IAction action, Collider collider = null, bool trigger = false)
    {
        if (action is ActionPickUp)
        {
            ActionPickUp pickUpAction = (ActionPickUp)action;
            pickUpAction.executePickUp(this);
            return(true);
        }
        else if (action is ActionTriggerRun)
        {
            ActionTriggerRun runActionTrigger = (ActionTriggerRun)action;
            return(this.setRunDirection(runActionTrigger, runActionTrigger.getDirection()));
        }
        else if (action is ActionRun)
        {
            ActionRun actionRun = action as ActionRun;
            if (trigger)
            {
                return(this.setRunDirection(actionRun, actionRun.GetTriggerDirection()));
            }
            if (this.wannaBeDirection != this.direction)
            {
                return(this.setRunDirection(actionRun, this.wannaBeDirection));
            }
        }
        else if (action is ActionSafetyNetForRun)
        {
            if (this.wannaBeDirection != this.direction)
            {
                return(((ActionSafetyNetForRun)action).EarlyMove(this.wannaBeDirection));
            }
        }
        else if (action is ActionTranslate)
        {
            ActionTranslate translateAction = (ActionTranslate)action;
            this.transform.Translate(translateAction.getTranslateVector(), Space.World);
            return(true);
        }
        else if (action is ActionSlide)
        {
            ActionSlide slideAction = action as ActionSlide;
            if (this.boarding && slideAction.slideStart)
            {
                if (this.inAir)
                {
                    this.offsetAnimator.SetBool("Slide", true);
                }
                else
                {
                    this.boarding = false;
                    //this.SetupBoarding();
                }
            }
            else
            {
                this.offsetAnimator.SetBool("Slide", false);
                this.offsetAnimator.SetTrigger("StartHover");
            }
        }
        else if (action is ActionJump)
        {
            ActionJump jumpAction = action as ActionJump;
            if (this.boarding && this.jumping == -1f)
            {
                this.jumping            = 0f;
                this.startJumpingVector = this.transform.position;
                this.endJumpingVector   = jumpAction.GetTargetPosition();
            }
        }
        else if (action is ActionDeath)
        {
            this.die(((ActionDeath)action).getType());
        }

        return(false);
    }
 // Use this for initialization;
 void Start()
 {
     actionJump = GetComponent <ActionJump> ();
     actionRun  = GetComponent <ActionRun> ();
 }
 private void RunBtnClick(object sender, EventArgs e)
 {
     ActionRun?.Invoke(sender, new ActionRunEventArgs());
 }