Ejemplo n.º 1
0
    private void Start()
    {
        // load local resources
        // (moving all logic from start function to this first time function)
        gameDataSaver = GetComponent <GameDataSaver>();
        logoutButton.onClick.AddListener(onLogout);
        exitButton.onClick.AddListener(onExit);
        logoutCanvas     = FindObjectOfType <LogoutCanvas>();
        questWindowUI    = FindObjectOfType <QuestWindowUI>();
        reviveController = FindObjectOfType <ReviveController>();
        hud              = FindObjectOfType <HUDController>();
        dialogueUI       = FindObjectOfType <DialogueUI>();
        actionBar        = GetComponentInChildren <ActionBarController>();
        inventoryManager = gameObject.GetComponentInChildren <InventoryManager>(true);
        inventory        = inventoryManager.inventory;
        equipment        = gameObject.GetComponentInChildren <EquipmentPanel>(true).equipment;

        // set up component
        logoutCanvas.gameObject.SetActive(false);
        hud.gameObject.SetActive(false);
        QuestManager.instance.questWindowUI = questWindowUI;
        DialogueManager.instance.dialogueUI = dialogueUI;
        StartCoroutine(LoadGameScene());
        exitButton.enabled = false;
        logoutButton.gameObject.SetActive(false);
        exitButton.gameObject.SetActive(false);

        // If game data exists in the database
        // Override the first stats load using the user data
        if (User.GetActiveCharacter().GameState.isDirty)
        {
            GameCharacter.Stats = GameCharacter.GetStatsFromData(UserService.Instance.User.GetActiveCharacter().GameState.Stats);
            GameCharacter.Stats.Setup();
        }
    }
Ejemplo n.º 2
0
    void Start()
    {
        if (MainMenuManager.sSingleton != null)
        {
            MainMenuManager.sSingleton.gameObject.SetActive(false);
            mRankOneHighScore = MainMenuManager.sSingleton.GetFirstRankTotalScore();

            List <int> selectedCharList = MainMenuManager.sSingleton.GetSelectedIndexList;
            List <ReviveController> reviveControllerList = new List <ReviveController>();
            int count = selectedCharList.Count;

            for (int i = 0; i < count; i++)
            {
                Transform trans = playerAndEnemyPrefabData.playerTransList[selectedCharList[i]];

                Sprite eyeshot = null;
                Sprite potrait = null;

                if (i == 0)
                {
                    Transform p1 = Instantiate(trans, p1StartPos.position, Quaternion.identity);
                    p1.tag = TagManager.sSingleton.player1Tag;

                    PlayerController pc = p1.GetComponent <PlayerController>();
                    pc.playerID    = 1;
                    pc.respawnXPos = p1RespawnXPos;
                    player1        = p1;

                    // Get the revive controller.
                    if (count == 2)
                    {
                        reviveControllerList.Add(p1.GetComponentInChildren <ReviveController>());
                    }

                    // Set character's image for left side player.
                    if (selectedCharList[i] == 0)
                    {
                        eyeshot = charInGameImageData.char1EyeshotLeft;
                        potrait = charInGameImageData.char1Potrait;
                    }
                    else if (selectedCharList[i] == 1)
                    {
                        eyeshot = charInGameImageData.char2EyeshotLeft;
                        potrait = charInGameImageData.char2Potrait;
                    }
                    else if (selectedCharList[i] == 2)
                    {
                        mMagnumPlayerID = 1;

                        eyeshot = charInGameImageData.char3EyeshotLeft;
                        potrait = charInGameImageData.char3Potrait;
                    }

                    BombManager.sSingleton.SetPlayerBombController(1, p1.GetComponent <BombController>());
                    BombManager.sSingleton.leftEyeshotImage.sprite = eyeshot;
                    BombManager.sSingleton.leftPotraitImage.sprite = potrait;
                }
                else
                {
                    Transform p2 = Instantiate(trans, p2StartPos.position, Quaternion.identity);
                    p2.tag = TagManager.sSingleton.player2Tag;

                    PlayerController pc = p2.GetComponent <PlayerController>();
                    pc.playerID    = 2;
                    pc.respawnXPos = p2RespawnXPos;
                    player2        = p2;

                    // Get the revive controller.
                    if (count == 2)
                    {
                        reviveControllerList.Add(p2.GetComponentInChildren <ReviveController>());
                    }

                    // Set character's image for right side player.
                    if (selectedCharList[i] == 0)
                    {
                        eyeshot = charInGameImageData.char1EyeshotRight;
                        potrait = charInGameImageData.char1Potrait;
                    }
                    else if (selectedCharList[i] == 1)
                    {
                        eyeshot = charInGameImageData.char2EyeshotRight;
                        potrait = charInGameImageData.char2Potrait;
                    }
                    else if (selectedCharList[i] == 2)
                    {
                        mMagnumPlayerID = 2;

                        eyeshot = charInGameImageData.char3EyeshotRight;
                        potrait = charInGameImageData.char3Potrait;
                    }

                    BombManager.sSingleton.SetPlayerBombController(2, p2.GetComponent <BombController>());
                    BombManager.sSingleton.rightEyeshotImage.sprite = eyeshot;
                    BombManager.sSingleton.rightPotraitImage.sprite = potrait;
                }
            }

            if (reviveControllerList.Count != 0)
            {
                for (int i = 0; i < reviveControllerList.Count; i++)
                {
                    reviveControllerList[i].UpdateWithinCirclePs();
                }
            }

            if (count == 1)
            {
                mP2Controller = null;
            }
        }
        else
        {
            mP1Controller = player1.GetComponent <PlayerController>();
            mP2Controller = player2.GetComponent <PlayerController>();

            Sprite eyeshot = null;
            Sprite potrait = null;

            if (mP1Controller.characterID == 1)
            {
                eyeshot = charInGameImageData.char1EyeshotLeft;
                potrait = charInGameImageData.char1Potrait;
            }
            else if (mP1Controller.characterID == 2)
            {
                eyeshot = charInGameImageData.char2EyeshotLeft;
                potrait = charInGameImageData.char2Potrait;
            }
            else if (mP1Controller.characterID == 3)
            {
                eyeshot = charInGameImageData.char3EyeshotLeft;
                potrait = charInGameImageData.char3Potrait;
            }

            BombManager.sSingleton.leftEyeshotImage.sprite = eyeshot;
            BombManager.sSingleton.leftPotraitImage.sprite = potrait;

            if (mP2Controller.characterID == 1)
            {
                eyeshot = charInGameImageData.char1EyeshotRight;
                potrait = charInGameImageData.char1Potrait;
            }
            else if (mP2Controller.characterID == 2)
            {
                eyeshot = charInGameImageData.char2EyeshotRight;
                potrait = charInGameImageData.char2Potrait;
            }
            else if (mP2Controller.characterID == 3)
            {
                eyeshot = charInGameImageData.char3EyeshotRight;
                potrait = charInGameImageData.char3Potrait;
            }

            BombManager.sSingleton.rightEyeshotImage.sprite = eyeshot;
            BombManager.sSingleton.rightPotraitImage.sprite = potrait;
        }

        InstantiateEnemy();
        InstantiateBullets();
        InstantiateEnvObj();

        mP1Controller       = player1.GetComponent <PlayerController>();
        mP2Controller       = player2.GetComponent <PlayerController>();
        mP1ReviveController = player1.GetComponentInChildren <ReviveController>();
        mP2ReviveController = player2.GetComponentInChildren <ReviveController>();
    }
Ejemplo n.º 3
0
 void Awake()
 {
     ReviveCtrl = this;
 }