Exemple #1
0
    // Use this for initialization
    void Start()
    {
        isGrounded  = false;
        justLanded  = true;
        gravityOn   = true;
        firstUpdate = false;

        gunOffset = new Vector3(0.0f, 0.75f, 0.50f);        //.02
        xSpeed    = 5;
        xMove     = 0.0f;

        jumpHeight    = STARTINGJUMPHEIGHT;
        jumpIncrease  = MAXJUMPINC;
        jumpFloatTime = MAXJUMPFLOATTIME;
        jumpTime      = MAXJUMPTIME;

        firstUpdateCounter = 0;

        input       = GetComponent <PlayerInput>();
        powers      = GetComponent <PlayerPowers>();
        wallJumping = GetComponent <WallJumping>();
        _HUD        = GetComponent <PlayerHUD>();
        anim        = GetComponent <AnimatorScript>();

        globals     = GameObject.Find("_Globals").GetComponent <GlobalsScript>();
        globalMusic = GameObject.Find("GlobalSoundEffects").GetComponent <GlobalMusicScript>();
        changeMusic = GameObject.Find("GlobalMusicChanger").GetComponent <ChangeVolumeGlitchMusic>();

        rb = GetComponent <Rigidbody>();
        rb.angularVelocity = Vector3.zero;
        rb.freezeRotation  = true;
    }
Exemple #2
0
    // Use this for initialization
    void Start()
    {
        canMove                 = true;
        phase                   = false;
        glide                   = false;
        jump                    = false;
        isWallJump              = false;
        debugOptions            = true;
        startingKanimiCode      = false;
        differentShootingButton = false;
        firstClingUpdate        = 0;
        canMoveCounter          = 0.0f;

        stopRumble();

        physics     = GetComponent <PlayerPhysics>();
        powers      = GetComponent <PlayerPowers>();
        wallJumping = GetComponent <WallJumping>();
        anim        = GetComponent <AnimatorScript>();
        globals     = GameObject.Find("_Globals").GetComponent <GlobalsScript>();
        globalMusic = GameObject.Find("GlobalSoundEffects").GetComponent <GlobalMusicScript>();

        globals.playerInputEnabled = true;
    }
Exemple #3
0
    //行動状態変数を初期化
    public void Initialize(GameObject usingObj)
    {
        PlayerCommandBase[] command = new PlayerCommandBase[15];
        waitingCommand             = usingObj.AddComponent <WaitingCommand>();
        runningCommand             = usingObj.AddComponent <RunningCommand>();
        slideRunningCommand        = usingObj.AddComponent <SlideRunningCommand>();
        jumpingFirstCommand        = usingObj.AddComponent <JumpingFirstCommand>();
        jumpingSecondCommand       = usingObj.AddComponent <JumpingSecondCommand>();
        jumpingWithUpToDownCommand = usingObj.AddComponent <JumpingWithUpToDownCommand>();
        slideJumpingCommand        = usingObj.AddComponent <SlideJumpingCommand>();
        wallJumpingCommand         = usingObj.AddComponent <WallJumpingCommand>();
        cliffHoldingCommand        = usingObj.AddComponent <CliffHoldingCommand>();
        attackingFirstCommand      = usingObj.AddComponent <AttackingFirstCommand>();
        attackingSecondCommand     = usingObj.AddComponent <AttackingSecondCommand>();
        attackingThirdCommand      = usingObj.AddComponent <AttackingThirdCommand>();
        attackingInAirCommand      = usingObj.AddComponent <AttackingInAirlialCommand>();
        nockBackingCommand         = usingObj.AddComponent <NockBackingCommand>();
        dyingCommand = usingObj.AddComponent <DyingCommand>();
        command[0]   = waitingCommand;
        command[1]   = runningCommand;
        command[2]   = slideRunningCommand;
        command[3]   = jumpingFirstCommand;
        command[4]   = jumpingSecondCommand;
        command[5]   = jumpingWithUpToDownCommand;
        command[6]   = slideJumpingCommand;
        command[7]   = wallJumpingCommand;
        command[8]   = cliffHoldingCommand;
        command[9]   = attackingFirstCommand;
        command[10]  = attackingSecondCommand;
        command[11]  = attackingThirdCommand;
        command[12]  = attackingInAirCommand;
        command[13]  = nockBackingCommand;
        command[14]  = dyingCommand;
        for (int i = 0; i < command.Length; i++)
        {
            command[i].Initialize(usingObj);
        }

        PlayerStateEntry[] move = new PlayerStateEntry[3];
        waiting      = usingObj.AddComponent <Waiting>();
        running      = usingObj.AddComponent <Running>();
        slideRunning = usingObj.AddComponent <SlideRunning>();
        move[0]      = waiting;
        move[1]      = running;
        move[2]      = slideRunning;
        for (int i = 0; i < move.Length; i++)
        {
            move[i].SubInitialize(usingObj);
        }

        PlayerStateEntry[] jump = new PlayerStateEntry[6];
        jumpingFirst        = usingObj.AddComponent <JumpingFirst>();
        jumpingSecond       = usingObj.AddComponent <JumpingSecond>();
        jumpingWithUpToDown = usingObj.AddComponent <JumpingWithUpToDown>();
        slideJumping        = usingObj.AddComponent <SlideJumping>();
        wallJumping         = usingObj.AddComponent <WallJumping>();
        cliffHolding        = usingObj.AddComponent <CliffHolding>();
        jump[0]             = jumpingFirst;
        jump[1]             = jumpingSecond;
        jump[2]             = jumpingWithUpToDown;
        jump[3]             = slideJumping;
        jump[4]             = wallJumping;
        jump[5]             = cliffHolding;
        for (int i = 0; i < jump.Length; i++)
        {
            jump[i].SubInitialize(usingObj);
        }

        PlayerStateEntry[] damage = new PlayerStateEntry[2];
        nockBacking = usingObj.AddComponent <NockBacking>();
        dying       = usingObj.AddComponent <Dying>();
        damage[0]   = nockBacking;
        damage[1]   = dying;
        for (int i = 0; i < damage.Length; i++)
        {
            damage[i].SubInitialize(usingObj);
        }

        PlayerStateEntry[] attack = new PlayerStateEntry[4];
        attackingFirst  = usingObj.AddComponent <AttackingFirst>();
        attackingSecond = usingObj.AddComponent <AttackingSecond>();;
        attackingThird  = usingObj.AddComponent <AttackingThird>();;
        attackingInAir  = usingObj.AddComponent <AttackingInAirlial>();;
        attack[0]       = attackingFirst;
        attack[1]       = attackingSecond;
        attack[2]       = attackingThird;
        attack[3]       = attackingInAir;
        for (int i = 0; i < attack.Length; i++)
        {
            attack[i].SubInitialize(usingObj);
        }

        PlayerStateEntry[] main = new PlayerStateEntry[4];
        moving    = usingObj.AddComponent <PlayerMovingStateMachine>();
        jumping   = usingObj.AddComponent <PlayerJumpingStateMachine>();
        attacking = usingObj.AddComponent <PlayerAttackingStateMachine>();
        damaging  = usingObj.AddComponent <PlayerDamagingStateMachine>();
        main[0]   = moving;
        main[1]   = jumping;
        main[2]   = attacking;
        main[3]   = damaging;
        for (int i = 0; i < main.Length; i++)
        {
            main[i].SubInitialize(usingObj);
        }

        usingObj.GetComponent <PlayerStateMachine>().SubInitialize(usingObj);
    }