예제 #1
0
 // Start is called before the first frame update
 void Start()
 {
     goalCollider      = GetComponent <BoxCollider2D>();
     playerCollider    = GameObject.FindGameObjectWithTag("Player").GetComponent <BoxCollider2D>();
     persisableObjects = GameObject.FindGameObjectWithTag("PersisableObject").GetComponent <PersisableObjects>();
     gameController    = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>();
 }
예제 #2
0
 void Start()
 {
     if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "StartScene")
     {
         charChoice      = GameObject.FindGameObjectWithTag("CharacterChoice");
         gameMode        = GameObject.FindGameObjectWithTag("GameMode");
         playerSelection = GameObject.FindGameObjectWithTag("PlayerSelection");
         startButton     = GameObject.FindGameObjectWithTag("StartButton");
         backButton      = GameObject.FindGameObjectWithTag("BackButton");
         backButton.SetActive(false);
         if (PersisableObjects.isCreated == true)
         {
             persisableObject = GameObject.FindGameObjectWithTag("PersisableObject").GetComponent <PersisableObjects>();
         }
     }
     else if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "Victory" || UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "GameOver")
     {
         highscore        = GameObject.FindGameObjectWithTag("HighScore").GetComponent <Text>();
         persisableObject = GameObject.FindGameObjectWithTag("PersisableObject").GetComponent <PersisableObjects>();
         highscore.text   = "Highscore: " + persisableObject.score;
     }
 }
    // Start is called before the first frame update
    void Start()
    {
        npcDialogue       = GameObject.FindGameObjectWithTag("NPC");
        persisableObjects = GameObject.FindGameObjectWithTag("PersisableObject").GetComponent <PersisableObjects>();
        playerTypes       = persisableObjects.playerTypes;
        LoadRoom(map);
        #region UI Setting
        player2UI = GameObject.FindGameObjectWithTag("Player2UI");
        player2UI.SetActive(false);
        playerController1        = GameObject.FindGameObjectsWithTag("Player")[0].GetComponent <PlayerController>();
        playerHealth1            = GameObject.FindGameObjectWithTag("Player1Health").GetComponent <Text>();
        Ability1Icon             = GameObject.FindGameObjectWithTag("P1Ability1Icon").GetComponent <Image>();
        Ability2Icon             = GameObject.FindGameObjectWithTag("P1Ability2Icon").GetComponent <Image>();
        Ability3Icon             = GameObject.FindGameObjectWithTag("P1Ability3Icon").GetComponent <Image>();
        ability1CD1              = GameObject.FindGameObjectWithTag("P1Ability1CD").GetComponent <TextMeshProUGUI>();
        ability2CD1              = GameObject.FindGameObjectWithTag("P1Ability2CD").GetComponent <TextMeshProUGUI>();
        ability3CD1              = GameObject.FindGameObjectWithTag("P1Ability3CD").GetComponent <TextMeshProUGUI>();
        scoreText                = GameObject.FindGameObjectWithTag("ScoreText");
        playerController1.Health = persisableObjects.player1hp;
        switch (playerTypes[0])
        {
        case 1:
            Ability1Icon.sprite = pheonixAbilityIcons[0];
            Ability2Icon.sprite = pheonixAbilityIcons[1];
            Ability3Icon.sprite = pheonixAbilityIcons[2];
            break;

        case 2:
            Ability1Icon.sprite = griffinAbilityIcons[0];
            Ability2Icon.sprite = griffinAbilityIcons[1];
            Ability3Icon.sprite = griffinAbilityIcons[2];
            break;

        case 3:
            Ability1Icon.sprite = dragonAbilityIcons[0];
            Ability2Icon.sprite = dragonAbilityIcons[1];
            Ability3Icon.sprite = dragonAbilityIcons[2];
            break;

        case 4:
            Ability1Icon.sprite = pegasusAbilityIcons[0];
            Ability2Icon.sprite = pegasusAbilityIcons[1];
            Ability3Icon.sprite = pegasusAbilityIcons[2];
            break;
        }

        if (persisableObjects.totalPlayers == 2)
        {
            player2UI.SetActive(true);
            playerController2        = GameObject.FindGameObjectsWithTag("Player")[1].GetComponent <PlayerController>();
            playerHealth2            = GameObject.FindGameObjectWithTag("Player2Health").GetComponent <Text>();
            Ability1Icon             = GameObject.FindGameObjectWithTag("P2Ability1Icon").GetComponent <Image>();
            Ability2Icon             = GameObject.FindGameObjectWithTag("P2Ability2Icon").GetComponent <Image>();
            Ability3Icon             = GameObject.FindGameObjectWithTag("P2Ability3Icon").GetComponent <Image>();
            ability1CD2              = GameObject.FindGameObjectWithTag("P2Ability1CD").GetComponent <TextMeshProUGUI>();
            ability2CD2              = GameObject.FindGameObjectWithTag("P2Ability2CD").GetComponent <TextMeshProUGUI>();
            ability3CD2              = GameObject.FindGameObjectWithTag("P2Ability3CD").GetComponent <TextMeshProUGUI>();
            playerController2.Health = persisableObjects.player2hp;

            switch (playerTypes[1])
            {
            case 1:
                Ability1Icon.sprite = pheonixAbilityIcons[0];
                Ability2Icon.sprite = pheonixAbilityIcons[1];
                Ability3Icon.sprite = pheonixAbilityIcons[2];
                break;

            case 2:
                Ability1Icon.sprite = griffinAbilityIcons[0];
                Ability2Icon.sprite = griffinAbilityIcons[1];
                Ability3Icon.sprite = griffinAbilityIcons[2];
                break;

            case 3:
                Ability1Icon.sprite = dragonAbilityIcons[0];
                Ability2Icon.sprite = dragonAbilityIcons[1];
                Ability3Icon.sprite = dragonAbilityIcons[2];
                break;

            case 4:
                Ability1Icon.sprite = pegasusAbilityIcons[0];
                Ability2Icon.sprite = pegasusAbilityIcons[1];
                Ability3Icon.sprite = pegasusAbilityIcons[2];
                break;
            }
        }
        score = persisableObjects.score;
        scoreText.GetComponent <Text>().text = "Score: " + persisableObjects.score;
        if (GoalController.level != 1)
        {
            npcDialogue.SetActive(false);
        }

        #endregion
    }
예제 #4
0
 // Start is called before the first frame update
 void Start()
 {
     #region Set Player-Based Axises
     GameController g = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>();
     g.IndexPlayer();
     instance      = g.PlayerNum;
     axisX         = "Horizontal" + instance;
     axisY         = "Vertical" + instance;
     attackAxis    = new string[4];
     attackAxis[0] = "P" + instance + "BasicAttack";
     for (int z = 1; z < 4; ++z)
     {
         attackAxis[z] = "P" + instance + "Ability" + z;
     }
     if (instance == 1)
     {
         instanceKeys[0, 0]     = "Z";
         instanceKeys[0, 1]     = "R";
         instanceKeys[1, 0]     = "X";
         instanceKeys[1, 1]     = "T";
         instanceKeys[2, 0]     = "C";
         instanceKeys[2, 1]     = "Y";
         instanceKeyCodes[0, 0] = KeyCode.Z;
         instanceKeyCodes[0, 1] = KeyCode.R;
         instanceKeyCodes[1, 0] = KeyCode.X;
         instanceKeyCodes[1, 1] = KeyCode.T;
         instanceKeyCodes[2, 0] = KeyCode.C;
         instanceKeyCodes[2, 1] = KeyCode.Y;
     }
     else
     {
         instanceKeys[0, 0]     = ",";
         instanceKeys[0, 1]     = "[";
         instanceKeys[1, 0]     = ".";
         instanceKeys[1, 1]     = "]";
         instanceKeys[2, 0]     = "/";
         instanceKeys[2, 1]     = "\\";
         instanceKeyCodes[0, 0] = KeyCode.Comma;
         instanceKeyCodes[0, 1] = KeyCode.LeftBracket;
         instanceKeyCodes[1, 0] = KeyCode.Period;
         instanceKeyCodes[1, 1] = KeyCode.RightBracket;
         instanceKeyCodes[2, 0] = KeyCode.Slash;
         instanceKeyCodes[2, 1] = KeyCode.Backslash;
     }
     #endregion
     #region Colliders
     playerCollider   = GetComponent <BoxCollider2D>();
     basicAttackRange = attackObject.GetComponent <CapsuleCollider2D>();
     #endregion
     #region Set Sprites
     for (int z = 0; z < 3; ++z)
     {
         playerImages[0, z] = north[z];
         playerImages[1, z] = east[z];
         playerImages[2, z] = south[z];
         playerImages[3, z] = west[z];
     }
     #endregion
     rbody             = GetComponent <Rigidbody2D>();
     sr                = GetComponent <SpriteRenderer>();
     gameController    = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>();
     persisableObjects = GameObject.FindGameObjectWithTag("PersisableObject").GetComponent <PersisableObjects>();
     status1           = this.gameObject.transform.GetChild(0).transform.GetChild(0).transform.GetChild(0).gameObject;
     status1.GetComponent <CanvasGroup>().alpha = 0f;
     if (GoalController.level == 1)
     {
         health = maximumHealth;
         persisableObjects.player1hp = gameController.playerController1.MaximumHealth;
         if (persisableObjects.totalPlayers == 2)
         {
             persisableObjects.player2hp = gameController.playerController2.MaximumHealth;
         }
     }
     else
     {
         if (persisableObjects.healthCode)
         {
             healthCode = true;
         }
     }
 }