コード例 #1
0
 // Start is called before the first frame update
 void Start()
 {
     onCookingStation = false;
     recipeBookImage.SetActive(false);
     ESP1                 = GameObject.Find("EnemySpawnerP1").GetComponent <EnemySpawnerP1>();
     ESP2                 = GameObject.Find("EnemySpawnerP2").GetComponent <EnemySpawnerP2>();
     ESP3                 = GameObject.Find("EnemySpawnerP3").GetComponent <EnemySpawnerP3>();
     ESP4                 = GameObject.Find("EnemySpawnerP4").GetComponent <EnemySpawnerP4>();
     levelLogicScript     = GameObject.Find("LevelLogic").GetComponent <LevelLogic>();
     sceneSwitchingScript = GameObject.Find("SceneSwitchingScript").GetComponent <SceneSwitchingScript>();
 }
コード例 #2
0
    // Start is called before the first frame update
    void Start()
    {
        HP = 100;
        moveSpeedDefault          = 8.0f;
        moveSpeed                 = moveSpeedDefault;
        moveSpeedEffectTimer      = 0;
        cheeseMoveSpeedSlowLength = 1.0f;
        myPlayer = GetComponent <PlayerMovement>();
        canMove  = true;

        levelLogicScript = GameObject.Find("LevelLogic").GetComponent <LevelLogic>();

        blackDeathScreenP1 = GameObject.Find("DeathBlackScreen_P1").GetComponent <SpriteRenderer>();
        blackDeathScreenP2 = GameObject.Find("DeathBlackScreen_P2").GetComponent <SpriteRenderer>();
        blackDeathScreenP3 = GameObject.Find("DeathBlackScreen_P3").GetComponent <SpriteRenderer>();
        blackDeathScreenP4 = GameObject.Find("DeathBlackScreen_P4").GetComponent <SpriteRenderer>();

        /*
         * HpText1 = GameObject.Find("UI_HP_Text_P1").GetComponent<Text>();
         * HpText2 = GameObject.Find("UI_HP_Text_P2").GetComponent<Text>();
         * HpText3 = GameObject.Find("UI_HP_Text_P3").GetComponent<Text>();
         * HpText4 = GameObject.Find("UI_HP_Text_P4").GetComponent<Text>();
         */
        /*
         * HpFill1 = GameObject.Find("UI_HP_Fill_P1").GetComponent<Image>();
         * HpFill2 = GameObject.Find("UI_HP_Fill_P2").GetComponent<Image>();
         * HpFill3 = GameObject.Find("UI_HP_Fill_P3").GetComponent<Image>();
         * HpFill4 = GameObject.Find("UI_HP_Fill_P4").GetComponent<Image>();
         */

        HpFill1 = GameObject.Find("UI_HPBar_P1").GetComponent <Image>();
        HpFill2 = GameObject.Find("UI_HPBar_P2").GetComponent <Image>();
        HpFill3 = GameObject.Find("UI_HPBar_P3").GetComponent <Image>();
        HpFill4 = GameObject.Find("UI_HPBar_P4").GetComponent <Image>();

        canvasP1 = GameObject.Find("Canvas_P1").GetComponent <Canvas>();
        canvasP2 = GameObject.Find("Canvas_P2").GetComponent <Canvas>();
        canvasP3 = GameObject.Find("Canvas_P3").GetComponent <Canvas>();
        canvasP4 = GameObject.Find("Canvas_P4").GetComponent <Canvas>();

        HpPlayerFill1 = GameObject.Find("UI_Player_HPBar_P1").GetComponent <Image>();
        HpPlayerFill2 = GameObject.Find("UI_Player_HPBar_P2").GetComponent <Image>();
        HpPlayerFill3 = GameObject.Find("UI_Player_HPBar_P3").GetComponent <Image>();
        HpPlayerFill4 = GameObject.Find("UI_Player_HPBar_P4").GetComponent <Image>();

        esP1 = GameObject.Find("EnemySpawnerP1").GetComponent <EnemySpawnerP1>();
        esP2 = GameObject.Find("EnemySpawnerP2").GetComponent <EnemySpawnerP2>();
        esP3 = GameObject.Find("EnemySpawnerP3").GetComponent <EnemySpawnerP3>();
        esP4 = GameObject.Find("EnemySpawnerP4").GetComponent <EnemySpawnerP4>();

        RedHitEffect_P1 = GameObject.Find("RedHitEffect_P1").GetComponent <Image>();
        RedHitEffect_P2 = GameObject.Find("RedHitEffect_P2").GetComponent <Image>();
        RedHitEffect_P3 = GameObject.Find("RedHitEffect_P3").GetComponent <Image>();
        RedHitEffect_P4 = GameObject.Find("RedHitEffect_P4").GetComponent <Image>();

        GreenHitEffect_P1 = GameObject.Find("GreenHitEffect_P1").GetComponent <Image>();
        GreenHitEffect_P2 = GameObject.Find("GreenHitEffect_P2").GetComponent <Image>();
        GreenHitEffect_P3 = GameObject.Find("GreenHitEffect_P3").GetComponent <Image>();
        GreenHitEffect_P4 = GameObject.Find("GreenHitEffect_P4").GetComponent <Image>();

        RedHitEffect_P1.enabled = false;
        RedHitEffect_P2.enabled = false;
        RedHitEffect_P3.enabled = false;
        RedHitEffect_P4.enabled = false;

        GreenHitEffect_P1.enabled = false;
        GreenHitEffect_P2.enabled = false;
        GreenHitEffect_P3.enabled = false;
        GreenHitEffect_P4.enabled = false;

        canvasP1.enabled = false;
        canvasP2.enabled = false;
        canvasP3.enabled = false;
        canvasP4.enabled = false;

        playerHPBarAppear_Timer_P1 = 0;
        playerHPBarAppear_Timer_P2 = 0;
        playerHPBarAppear_Timer_P3 = 0;
        playerHPBarAppear_Timer_P4 = 0;

        recipeBookScript_P1 = GameObject.Find("CraftingOven_S1").GetComponent <RecipeBook>();
        recipeBookScript_P2 = GameObject.Find("CraftingOven_S2").GetComponent <RecipeBook>();
        recipeBookScript_P3 = GameObject.Find("CraftingOven_S3").GetComponent <RecipeBook>();
        recipeBookScript_P4 = GameObject.Find("CraftingOven_S4").GetComponent <RecipeBook>();

        blindEffectScript = GetComponent <BlindEffect>();

        redChefHitEffect_Head.enabled = false;
        redChefHitEffect_Body.enabled = false;

        //setting inputBackButton
        //not mac
        if (!myPlayer.isMac)
        {
            if (SceneSwitchingScript.isXbox == true)
            {
                if (myPlayer.player1)
                {
                    inputBack = "Xbox_Button_Back_P1";
                }
                else if (myPlayer.player2)
                {
                    inputBack = "Xbox_Button_Back_P2";
                }
                else if (myPlayer.player3)
                {
                    inputBack = "Xbox_Button_Back_P3";
                }
                else if (myPlayer.player4)
                {
                    inputBack = "Xbox_Button_Back_P4";
                }
            }
            else if (SceneSwitchingScript.isXbox == false)
            {
                if (myPlayer.player1)
                {
                    inputBack = "PS4_Button_Back_P1";
                }
                else if (myPlayer.player2)
                {
                    inputBack = "PS4_Button_Back_P2";
                }
                else if (myPlayer.player3)
                {
                    inputBack = "PS4_Button_Back_P3";
                }
                else if (myPlayer.player4)
                {
                    inputBack = "PS4_Button_Back_P4";
                }
            }
        }
        //mac
        else if (myPlayer.isMac)
        {
            if (SceneSwitchingScript.isXbox == true)
            {
                if (myPlayer.player1)
                {
                    inputBack = "Xbox_Button_Back_P1_MAC";
                }
                else if (myPlayer.player2)
                {
                    inputBack = "Xbox_Button_Back_P2_MAC";
                }
                else if (myPlayer.player3)
                {
                    inputBack = "Xbox_Button_Back_P3_MAC";
                }
                else if (myPlayer.player4)
                {
                    inputBack = "Xbox_Button_Back_P4_MAC";
                }
            }
            else if (SceneSwitchingScript.isXbox == false)
            {
                if (myPlayer.player1)
                {
                    inputBack = "PS4_Button_Back_P1";
                }
                else if (myPlayer.player2)
                {
                    inputBack = "PS4_Button_Back_P2";
                }
                else if (myPlayer.player3)
                {
                    inputBack = "PS4_Button_Back_P3";
                }
                else if (myPlayer.player4)
                {
                    inputBack = "PS4_Button_Back_P4";
                }
            }
        }

        controlsOpen          = false;
        ControlsImage.enabled = false;

        if (SceneSwitchingScript.isXbox == true)
        {
            ControlsButton.enabled  = true;
            ControlsButtonP.enabled = false;
        }
        else if (SceneSwitchingScript.isXbox == false)
        {
            ControlsButton.enabled  = false;
            ControlsButtonP.enabled = true;
        }
    }