Example #1
0
    public void onPickUp()
    {
        pickUpAudio.Play();
        state = PickUpState.BeingPickedUp;
        Hashtable t = new Hashtable();

        //t ["a"] = 0.0f;
        //t ["delay"] = 1.0f;
        //t ["time"] = 3;
        //t ["onComplete"] = "kill";
        t.Add("alpha", 0.0);
        t.Add("delay", 0.0);
        t.Add("time", 3);
        //Color c = renderer.material.GetColor ("_Color");
        //renderer.material.SetColor("_Color", new Color(c.r, c.g, c.b, 0.5f));
        //iTween.FadeTo(gameObject,iTween.Hash("alpha", 0, "time", 3, "delay", 1));
        //iTween.FadeTo(gameObject, t);
        //iTween.MoveTo(gameObject, Vector3(0,0,0), 3);

        //gameObject.SetActive (false);

        /*iTween.MoveBy(gameObject, iTween.Hash("z", 3.0f,
         *      "easeType", "easeInOutExpo",
         *      "loopType", "pingPong",
         *      "islocal", true,
         *      "delay", .1));*/
        //iTween.MoveTo (gameObject, new Vector3 (transform.position.x, transform.position.y+5, transform.position.z), 2.0f);
        iTween.FadeTo(gameObject, 0.0f, 1.0f);
        gameObject.SetActive(false);
    }
 public virtual void Discard()
 {
     rb.bodyType = RigidbodyType2D.Dynamic;
     //Orphanize
     transform.SetParent(null);
     //Prevent any weird scaling
     transform.localScale = Vector3.one;
     state = PickUpState.Idle;
 }
 public virtual void PickUp(SwordController sword)
 {
     rb.bodyType = RigidbodyType2D.Kinematic;
     transform.DOKill();
     transform.SetParent(sword.bladePos);
     transform.localPosition = Vector3.zero;
     transform.localRotation = sword.transform.rotation;
     state = PickUpState.PickedUp;
 }
Example #4
0
    private void ConstructFSM()
    {
        IdleState idle = new IdleState();

        idle.AddTransition(FSMTransitionType.CanBeMove, FSMStateType.Move);
        idle.AddTransition(FSMTransitionType.AttackWithSingleWield, FSMStateType.SingleWieldAttack);
        idle.AddTransition(FSMTransitionType.AttackWithDoubleHands, FSMStateType.DoubleHandsAttack);
        idle.AddTransition(FSMTransitionType.UsingRipple, FSMStateType.RippleAttack);
        idle.AddTransition(FSMTransitionType.UsingHeartAttack, FSMStateType.HeartAttack);
        idle.AddTransition(FSMTransitionType.UsingStygianDesolator, FSMStateType.StygianDesolator);
        idle.AddTransition(FSMTransitionType.UsingIceArrow, FSMStateType.IceArrow);
        idle.AddTransition(FSMTransitionType.UsingChoshimArrow, FSMStateType.ChoshimArrow);
        idle.AddTransition(FSMTransitionType.CanPickUp, FSMStateType.PickUp);
        idle.AddTransition(FSMTransitionType.UsingThunderBolt, FSMStateType.ThunderBolt);
        idle.AddTransition(FSMTransitionType.AttackWithSpear, FSMStateType.SpearAttack);
        idle.AddTransition(FSMTransitionType.CanDefend, FSMStateType.Defend);
        idle.AddTransition(FSMTransitionType.Falling, FSMStateType.Fall);

        MoveState move = new MoveState();

        move.AddTransition(FSMTransitionType.IsIdle, FSMStateType.Idle);
        move.AddTransition(FSMTransitionType.AttackWithSingleWield, FSMStateType.SingleWieldAttack);
        move.AddTransition(FSMTransitionType.AttackWithDoubleHands, FSMStateType.DoubleHandsAttack);
        move.AddTransition(FSMTransitionType.AttackWithSpear, FSMStateType.SpearAttack);



        DefendState defend = new DefendState();

        defend.AddTransition(FSMTransitionType.IsIdle, FSMStateType.Idle);

        SingleWieldAttackState singleWieldAttack = new SingleWieldAttackState();

        singleWieldAttack.AddTransition(FSMTransitionType.IsIdle, FSMStateType.Idle);
        singleWieldAttack.AddTransition(FSMTransitionType.AttackWithSingleWield, FSMStateType.SingleWieldAttack);
        singleWieldAttack.AddTransition(FSMTransitionType.CanBeMove, FSMStateType.Move);

        DoubleHandsAttackState dualWieldAttack = new DoubleHandsAttackState();

        dualWieldAttack.AddTransition(FSMTransitionType.IsIdle, FSMStateType.Idle);
        dualWieldAttack.AddTransition(FSMTransitionType.AttackWithDoubleHands, FSMStateType.DoubleHandsAttack);
        dualWieldAttack.AddTransition(FSMTransitionType.CanBeMove, FSMStateType.Move);


        SpearAttackState spearAttack = new SpearAttackState();

        spearAttack.AddTransition(FSMTransitionType.IsIdle, FSMStateType.Idle);
        spearAttack.AddTransition(FSMTransitionType.CanBeMove, FSMStateType.Move);

        RippleAttackState rippleAttack = new RippleAttackState();

        rippleAttack.AddTransition(FSMTransitionType.IsIdle, FSMStateType.Idle);

        HeartAttackState heartAttack = new HeartAttackState();

        heartAttack.AddTransition(FSMTransitionType.IsIdle, FSMStateType.Idle);

        StygianDesolatorState stygianDesolator = new StygianDesolatorState();

        stygianDesolator.AddTransition(FSMTransitionType.IsIdle, FSMStateType.Idle);

        IceArrowState iceArrow = new IceArrowState();

        iceArrow.AddTransition(FSMTransitionType.IsIdle, FSMStateType.Idle);

        ChoshimArrowState choshimArrow = new ChoshimArrowState();

        choshimArrow.AddTransition(FSMTransitionType.IsIdle, FSMStateType.Idle);

        ThunderBoltState thunderBolt = new ThunderBoltState();

        thunderBolt.AddTransition(FSMTransitionType.IsIdle, FSMStateType.Idle);

        PickUpState pickUp = new PickUpState();

        pickUp.AddTransition(FSMTransitionType.IsIdle, FSMStateType.Idle);

        FallState fall = new FallState();

        fall.AddTransition(FSMTransitionType.IsIdle, FSMStateType.Idle);



        AddFSMState(idle);
        AddFSMState(move);
        AddFSMState(defend);
        AddFSMState(singleWieldAttack);
        AddFSMState(dualWieldAttack);
        AddFSMState(rippleAttack);
        AddFSMState(heartAttack);
        AddFSMState(stygianDesolator);
        AddFSMState(iceArrow);
        AddFSMState(choshimArrow);
        AddFSMState(thunderBolt);
        AddFSMState(pickUp);
        AddFSMState(spearAttack);
        AddFSMState(fall);
    }
Example #5
0
 // Use this for initialization
 void Start()
 {
     pickUpAudio = GetComponentInParent <AudioSource> ();
     state       = PickUpState.Alive;
     renderer    = GetComponent <Renderer> ();
 }
Example #6
0
    private void MakeFSM()
    {
        NormalIdleState normalIdle = new NormalIdleState(this.transform);

        normalIdle.AddTransition(Transition.NormalIdleTSTurnR, StateID.TurnR);           //
        normalIdle.AddTransition(Transition.NormalIdleTSTurnL, StateID.TurnL);           //
        normalIdle.AddTransition(Transition.NormalIdleTSNormalMove, StateID.NormalMove); //
        normalIdle.AddTransition(Transition.NormalIdleTSFightIdle, StateID.FightIdle);   //
        normalIdle.AddTransition(Transition.NormalIdleTSSprint, StateID.Sprint);         //
        normalIdle.AddTransition(Transition.NormalIdleTSCoverR, StateID.CoverR);         //
        normalIdle.AddTransition(Transition.NormalIdleTSCoverL, StateID.CoverL);         //
        normalIdle.AddTransition(Transition.NormalIdleTSCoverHiR, StateID.CoverHiR);
        normalIdle.AddTransition(Transition.NormalIdleTSCoverHiL, StateID.CoverHiL);
        normalIdle.AddTransition(Transition.NormalIdleTSPickUp, StateID.PickUp);     //
        normalIdle.AddTransition(Transition.NormalIdleTSOpenDoor, StateID.OpenDoor); //
        normalIdle.AddTransition(Transition.NormalIdleTSUsePad, StateID.UsePad);     //

        TurnRState turnR = new TurnRState(this.transform);

        turnR.AddTransition(Transition.TurnRTSTurnL, StateID.TurnL);
        turnR.AddTransition(Transition.TurnRTSNormalIdle, StateID.NormalIdle);
        turnR.AddTransition(Transition.TurnRTSNormalMove, StateID.NormalMove);

        TurnLState turnL = new TurnLState(this.transform);

        turnL.AddTransition(Transition.TurnLTSNormalIdle, StateID.NormalIdle);
        turnL.AddTransition(Transition.TurnLTSNormalMove, StateID.NormalMove);

        FightIdleState fightIdle = new FightIdleState(this.transform);

        fightIdle.AddTransition(Transition.FightIdleTSFightMove, StateID.FightMove);   //
        fightIdle.AddTransition(Transition.FightIdleTSNormalMove, StateID.NormalMove); //
        fightIdle.AddTransition(Transition.FightIdleTSNormalIdle, StateID.NormalIdle); //

        NormalMoveState normalMove = new NormalMoveState(this.transform);

        normalMove.AddTransition(Transition.NormalMoveTSFightMove, StateID.FightMove);   //
        normalMove.AddTransition(Transition.NormalMoveTSNormalIdle, StateID.NormalIdle); //
        normalMove.AddTransition(Transition.NormalMoveTSSprint, StateID.Sprint);         //
        normalMove.AddTransition(Transition.NormalMoveTSRoll, StateID.Roll);             //
        normalMove.AddTransition(Transition.NormalMoveTSCoverR, StateID.CoverR);         //
        normalMove.AddTransition(Transition.NormalMoveTSCoverL, StateID.CoverL);         //
        normalMove.AddTransition(Transition.NormalMoveTSCoverHiR, StateID.CoverHiR);
        normalMove.AddTransition(Transition.NormalMoveTSCoverHiL, StateID.CoverHiL);
        normalMove.AddTransition(Transition.NormalMoveTSOpenDoor, StateID.OpenDoor); //
        normalMove.AddTransition(Transition.NormalMoveTSUsePad, StateID.UsePad);     //

        FightMoveState fightMove = new FightMoveState(this.transform);

        fightMove.AddTransition(Transition.FightMoveTSFightIdle, StateID.FightIdle);   //
        fightMove.AddTransition(Transition.FightMoveTSNormalMove, StateID.NormalMove); //

        RollState roll = new RollState(this.transform);

        roll.AddTransition(Transition.RollTSNormalIdle, StateID.NormalIdle); //
        roll.AddTransition(Transition.RollTSNormalMove, StateID.NormalMove); //

        SprintState sprint = new SprintState(this.transform);

        sprint.AddTransition(Transition.SprintTSNormalIdle, StateID.NormalIdle); //
        sprint.AddTransition(Transition.SprintTSNormalMove, StateID.NormalMove); //
        sprint.AddTransition(Transition.SprintTSCoverR, StateID.CoverR);         //
        sprint.AddTransition(Transition.SprintTSCoverL, StateID.CoverL);         //
        sprint.AddTransition(Transition.SprintTSRoll, StateID.Roll);             //
        sprint.AddTransition(Transition.SprintTSCoverHiR, StateID.CoverHiR);
        sprint.AddTransition(Transition.SprintTSCoverHiL, StateID.CoverHiL);
        sprint.AddTransition(Transition.SprintTSOpenDoor, StateID.OpenDoor); //
        sprint.AddTransition(Transition.SprintTSUsePad, StateID.UsePad);     //

        CoverJumpState coverJump = new CoverJumpState(this.transform);

        coverJump.AddTransition(Transition.CoverJumpTSNormalIdle, StateID.NormalIdle);//

        CoverRState coverR = new CoverRState(this.transform);

        coverR.AddTransition(Transition.CoverRTSCoverL, StateID.CoverL);                       //
        coverR.AddTransition(Transition.CoverRTSRoll, StateID.Roll);                           //
        coverR.AddTransition(Transition.CoverRTSNormalMove, StateID.NormalMove);               //
        coverR.AddTransition(Transition.CoverRTSCoverJump, StateID.CoverJump);                 //
        coverR.AddTransition(Transition.CoverRTSCoverLoRShootIdle, StateID.CoverLoRShootIdle); //
        coverR.AddTransition(Transition.CoverRTSCoverRReload, StateID.CoverRReload);           //
        coverR.AddTransition(Transition.CoverRTSNormalIdle, StateID.NormalIdle);               //

        CoverLoRShootIdleState coverLoRShootIdle = new CoverLoRShootIdleState(this.transform);

        coverLoRShootIdle.AddTransition(Transition.CoverLoRShootIdleTSCoverLoRShootBeforeDown, StateID.CoverLoRShootBeforeDown); //
        coverLoRShootIdle.AddTransition(Transition.CoverLoRShootIdleTSFightIdle, StateID.FightIdle);                             //
        coverLoRShootIdle.AddTransition(Transition.CoverLoRShootIdleTSCoverR, StateID.CoverR);                                   //

        CoverLoRShootBeforeDownState coverLoRShootBeforeDown = new CoverLoRShootBeforeDownState(this.transform);

        coverLoRShootBeforeDown.AddTransition(Transition.CoverLoRShootBeforeDownTSCoverR, StateID.CoverR);                       //
        coverLoRShootBeforeDown.AddTransition(Transition.CoverLoRShootBeforeDownTSCoverLoRShootIdle, StateID.CoverLoRShootIdle); //
        coverLoRShootBeforeDown.AddTransition(Transition.CoverLoRShootBeforeDownTSNormalIdle, StateID.NormalIdle);               //

        CoverLState coverL = new CoverLState(this.transform);

        coverL.AddTransition(Transition.CoverLTSCoverR, StateID.CoverR);                       //
        coverL.AddTransition(Transition.CoverLTSRoll, StateID.Roll);                           //
        coverL.AddTransition(Transition.CoverLTSNormalMove, StateID.NormalMove);               //
        coverL.AddTransition(Transition.CoverLTSCoverJump, StateID.CoverJump);                 //
        coverL.AddTransition(Transition.CoverLTSCoverLoLShootIdle, StateID.CoverLoLShootIdle); //
        coverL.AddTransition(Transition.CoverLTSCoverLReload, StateID.CoverLReload);           //
        coverL.AddTransition(Transition.CoverLTSNormalIdle, StateID.NormalIdle);               //

        CoverLoLShootIdleState coverLoLShootIdle = new CoverLoLShootIdleState(this.transform);

        coverLoLShootIdle.AddTransition(Transition.CoverLoLShootIdleTSCoverLoLShootBeforeDown, StateID.CoverLoLShootBeforeDown); //
        coverLoLShootIdle.AddTransition(Transition.CoverLoLShootIdleTSFightIdle, StateID.FightIdle);                             //
        coverLoLShootIdle.AddTransition(Transition.CoverLoLShootIdleTSCoverL, StateID.CoverL);                                   //

        CoverLoLShootBeforeDownState coverLoLShootBeforeDown = new CoverLoLShootBeforeDownState(this.transform);

        coverLoLShootBeforeDown.AddTransition(Transition.CoverLoLShootBeforeDownTSCoverL, StateID.CoverL);                       //
        coverLoLShootBeforeDown.AddTransition(Transition.CoverLoLShootBeforeDownTSCoverLoLShootIdle, StateID.CoverLoLShootIdle); //
        coverLoLShootBeforeDown.AddTransition(Transition.CoverLoLShootBeforeDownTSNormalIdle, StateID.NormalIdle);               //

        CoverHiRState coverHiR = new CoverHiRState(this.transform);

        coverHiR.AddTransition(Transition.CoverHiRTSCoverHiL, StateID.CoverHiL);
        coverHiR.AddTransition(Transition.CoverHiRTSNormalMove, StateID.NormalMove);
        coverHiR.AddTransition(Transition.CoverHiRTSCoverHiRightIdle, StateID.CoverHiRightIdle);
        coverHiR.AddTransition(Transition.CoverHiRTSNormalIdle, StateID.NormalIdle);

        CoverHiRightIdleState coverHiRightIdle = new CoverHiRightIdleState(this.transform);

        coverHiRightIdle.AddTransition(Transition.CoverHiRightIdleTSCoverHiR, StateID.CoverHiR);
        coverHiRightIdle.AddTransition(Transition.CoverHiRightIdleTSRoll, StateID.Roll);
        coverHiRightIdle.AddTransition(Transition.CoverHiRightIdleTSCoverHiRShootIdle, StateID.CoverHiRShootIdle);
        coverHiRightIdle.AddTransition(Transition.CoverHiRightIdleTSNormalIdle, StateID.NormalIdle);

        CoverHiRShootIdleState coverHiRShootIdle = new CoverHiRShootIdleState(this.transform);

        coverHiRShootIdle.AddTransition(Transition.CoverHiRShootIdleTSCoverHiRShootBeforeDown, StateID.CoverHiRShootBeforeDown);
        coverHiRShootIdle.AddTransition(Transition.CoverHiRShootIdleTSCoverHiRightIdle, StateID.CoverHiRightIdle);
        coverHiRShootIdle.AddTransition(Transition.CoverHiRShootIdleTSFightIdle, StateID.FightIdle);

        CoverHiRShootBeforeDownState coverHiRShootBeforeDown = new CoverHiRShootBeforeDownState(this.transform);

        coverHiRShootBeforeDown.AddTransition(Transition.CoverHiRShootBeforeDownTSCoverHiRightIdle, StateID.CoverHiRightIdle);
        coverHiRShootBeforeDown.AddTransition(Transition.CoverHiRShootBeforeDownTSCoverHiRShootIdle, StateID.CoverHiRShootIdle);
        coverHiRShootBeforeDown.AddTransition(Transition.CoverHiRShootBeforeDownTSNormalIdle, StateID.NormalIdle);

        CoverHiLState coverHiL = new CoverHiLState(this.transform);

        coverHiL.AddTransition(Transition.CoverHiLTSCoverHiR, StateID.CoverHiR);
        coverHiL.AddTransition(Transition.CoverHiLTSNormalMove, StateID.NormalMove);
        coverHiL.AddTransition(Transition.CoverHiLTSCoverHiLeftIdle, StateID.CoverHiLeftIdle);
        coverHiL.AddTransition(Transition.CoverHiLTSNormalIdle, StateID.NormalIdle);

        CoverHiLeftIdleState coverHiLeftIdle = new CoverHiLeftIdleState(this.transform);

        coverHiLeftIdle.AddTransition(Transition.CoverHiLeftIdleTSCoverHiL, StateID.CoverHiL);
        coverHiLeftIdle.AddTransition(Transition.CoverHiLeftIdleTSRoll, StateID.Roll);
        coverHiLeftIdle.AddTransition(Transition.CoverHiLeftIdleTSCoverHiLShootIdle, StateID.CoverHiLShootIdle);
        coverHiLeftIdle.AddTransition(Transition.CoverHiLeftIdleTSNormalIdle, StateID.NormalIdle);

        CoverHiLShootIdleState coverHiLShootIdle = new CoverHiLShootIdleState(this.transform);

        coverHiLShootIdle.AddTransition(Transition.CoverHiLShootIdleTSCoverHiLShootBeforeDown, StateID.CoverHiLShootBeforeDown);
        coverHiLShootIdle.AddTransition(Transition.CoverHiLShootIdleTSCoverHiLeftIdle, StateID.CoverHiLeftIdle);
        coverHiLShootIdle.AddTransition(Transition.CoverHiRShootIdleTSFightIdle, StateID.FightIdle);


        CoverHiLShootBeforeDownState coverHiLShootBeforeDown = new CoverHiLShootBeforeDownState(this.transform);

        coverHiLShootBeforeDown.AddTransition(Transition.CoverHiLShootBeforeDownTSCoverHiLeftIdle, StateID.CoverHiLeftIdle);
        coverHiLShootBeforeDown.AddTransition(Transition.CoverHiLShootBeforeDownTSCoverHiLShootIdle, StateID.CoverHiLShootIdle);
        coverHiLShootBeforeDown.AddTransition(Transition.CoverHiLShootBeforeDownTSNormalIdle, StateID.NormalIdle);

        CoverRReloadState coverRReloadState = new CoverRReloadState(this.transform);

        coverRReloadState.AddTransition(Transition.CoverRReloadTSCoverR, StateID.CoverR);//

        CoverLReloadState coverLReloadState = new CoverLReloadState(this.transform);

        coverLReloadState.AddTransition(Transition.CoverLReloadTSCoverL, StateID.CoverL);//

        PickUpState pickUpState = new PickUpState(this.transform);

        pickUpState.AddTransition(Transition.PickUpTSNormalIdle, StateID.NormalIdle);//

        OpenDoorState openDoorState = new OpenDoorState(this.transform);

        openDoorState.AddTransition(Transition.OpenDoorTSNormalIdle, StateID.NormalIdle);//

        UsePadState usePadState = new UsePadState(this.transform);

        usePadState.AddTransition(Transition.UsePadTSNormalIdle, StateID.NormalIdle);//


        fsm = new FSMSystem();

        fsm.AddState(normalIdle);
        fsm.AddState(normalMove);
        fsm.AddState(roll);
        fsm.AddState(sprint);
        fsm.AddState(fightIdle);
        fsm.AddState(fightMove);
        fsm.AddState(coverR);
        fsm.AddState(coverL);
        fsm.AddState(coverJump);
        fsm.AddState(turnR);
        fsm.AddState(turnL);
        fsm.AddState(coverHiR);
        fsm.AddState(coverHiL);
        fsm.AddState(coverHiRightIdle);
        fsm.AddState(coverHiLeftIdle);
        fsm.AddState(coverHiRShootIdle);
        fsm.AddState(coverHiRShootBeforeDown);
        fsm.AddState(coverHiLShootIdle);
        fsm.AddState(coverHiLShootBeforeDown);
        fsm.AddState(coverLoRShootIdle);
        fsm.AddState(coverLoRShootBeforeDown);
        fsm.AddState(coverLoLShootIdle);
        fsm.AddState(coverLoLShootBeforeDown);
        fsm.AddState(coverRReloadState);
        fsm.AddState(coverLReloadState);
        fsm.AddState(pickUpState);
        fsm.AddState(openDoorState);
        fsm.AddState(usePadState);
    }