Esempio n. 1
0
    /// <summary>
    /// Command to setup the duel opponent and all necessary components required
    /// for executing the AI correctly
    /// </summary>
    public void btn_Duel()
    {
        glob_audiomanager.SendMessage("PlayClickA");
        //When this button is pressed we need too
        //1.Instatiate the Duel Opponent Controller
        //2.Pass all the options and AI details to the Controller
        //3.Load the Duel Scene
        if (GameObject.FindGameObjectWithTag("DUEL_OPPONENT") == null)
        {
            Instantiate(duel_opponent_prefab, new Vector3(0.0f, 0.0f, 0.0f),
                        Quaternion.identity);

            AIDetails dOpponent = GameObject.
                                  FindGameObjectWithTag("DUEL_OPPONENT").
                                  GetComponent <AIDetails> ();
            DuelOptions duelOpts = GameObject.
                                   FindGameObjectWithTag("DUEL_OPPONENT").
                                   GetComponent <DuelOptions> ();

            AIDetails sOpponent = selectedAI.GetComponent <AIDetails> ();
            //Assign everything to the new Duel opponent object
            dOpponent.ai_name        = sOpponent.ai_name;
            dOpponent.ai_deckname    = sOpponent.ai_deckname;
            dOpponent.ai_image       = sOpponent.ai_image;
            dOpponent.ai_unlocklevel = sOpponent.ai_unlocklevel;
            dOpponent.ai_decklist    = sOpponent.ai_decklist;

            dOpponent.ai_winExp  = sOpponent.ai_winExp;
            dOpponent.ai_lossExp = sOpponent.ai_lossExp;
            dOpponent.ai_drawExp = sOpponent.ai_drawExp;

            dOpponent.speech_DuelStart    = sOpponent.speech_DuelStart;
            dOpponent.speech_EndTurn      = sOpponent.speech_EndTurn;
            dOpponent.speech_DrawCard     = sOpponent.speech_DrawCard;
            dOpponent.speech_SummonCard   = sOpponent.speech_SummonCard;
            dOpponent.speech_SetCard      = sOpponent.speech_SetCard;
            dOpponent.speech_DirectAttack = sOpponent.speech_DirectAttack;
            dOpponent.speech_NormalAttack = sOpponent.speech_NormalAttack;

            duelOpts.duelopt_traditionalrules = ui_toggleTraditional.isOn;
            duelOpts.duelopt_monstersonly     = ui_toggleMonstersOnly.isOn;
            duelOpts.duelopt_noeffectmonsters = ui_toggleNoEffect.isOn;

            duelOpponentLoaded = true;
        }
    }
    void Start()
    {
        //Get the game management objects
        glob_gamemanager  = GameObject.FindGameObjectWithTag("GameManager");
        glob_audiomanager = GameObject.FindGameObjectWithTag("audio_manager");
        //Get the duel opponent object
        duel_opponent = GameObject.FindGameObjectWithTag("DUEL_OPPONENT");
        //Get the AI and then Duel Options
        duel_ai      = duel_opponent.GetComponent <AI> ();
        duel_options = duel_opponent.GetComponent <DuelOptions> ();

        //Setup the game based on the duel options the player has selected
        if (duel_options.duelopt_traditionalrules)
        {
            duel_ai.ai_LifePoints     = 4000;
            duel_ai.ai_liveLifePoints = 4000;
            player_lifePoints         = 4000;
            player_liveLifePoints     = 4000;
        }

        //Setup player objects
        player_Graveyard = new List <Card> ();
        //Setup the Player and AI profile pictures as they do not change
        //during the duel
        ui_img_PlayerPicture.sprite = glob_gamemanager.
                                      GetComponent <AccountController>().LoggedInAccount.DisplayPicture;
        ui_img_AIPicture.sprite = duel_opponent.
                                  GetComponent <AIDetails> ().ai_image;
        //Setup the Player and AI names as these also do not change
        ui_lbl_playerName.text = glob_gamemanager.
                                 GetComponent <AccountController>().LoggedInAccount.Username;
        ui_lbl_aiName.text = duel_opponent.
                             GetComponent <AIDetails> ().ai_name;

        //Get the AI monster zones
        foreach (DuelMonsterZoneScript script in ui_ai_monsterZones)
        {
            duel_ai.ai_monsterzones.Add(script);
        }
        duel_opponent.SendMessage("CommandLoadAI", this);          //Tell the AI
        //to start loading up!
    }
    void Start()
    {
        //Get the necessary Managers
        glob_gamemanager  = GameObject.FindGameObjectWithTag("GameManager");
        glob_audiomanager = GameObject.FindGameObjectWithTag("audio_manager");
        //Get the information on the Duel Opponent/AI
        duel_opponent = GameObject.FindGameObjectWithTag("DUEL_OPPONENT");
        //Get player Account details
        accountControl = glob_gamemanager.GetComponent <AccountController> ();
        //Get the AI details
        ai_details = duel_opponent.GetComponent <AIDetails> ();
        duel_opts  = duel_opponent.GetComponent <DuelOptions> ();
        //Determine if the Player Lost,Won,or Drew the game
        hasPlayerLost = duel_opts.hasPlayerLost;
        hasDrawnGame  = duel_opts.hasDrawnGame;
        //Assign the appropriate amount of EXP
        if (hasDrawnGame)
        {
            hasLeveledUp = accountControl.AddDraw(ai_details.ai_drawExp);
            rewardsText += ai_details.ai_drawExp.ToString() + "xp,";
        }
        else
        {
            if (hasPlayerLost)
            {
                hasLeveledUp = accountControl.AddLoss(ai_details.ai_lossExp);
                rewardsText += ai_details.ai_lossExp.ToString() + "xp,";
            }
            else
            {
                hasLeveledUp = accountControl.AddWin(ai_details.ai_winExp);
                rewardsText += ai_details.ai_winExp.ToString() + "xp,";
            }
        }
        //Set the rewards text and place the new lines where assigned
        rewardsText = rewardsText.Replace(",", "\n");
        //Assign player and AI profile pictures
        ui_img_playerDisplay.sprite =
            accountControl.LoggedInAccount.DisplayPicture;
        ui_img_aiDisplay.sprite = ai_details.ai_image;
        //Assign player and AI names to the UI
        ui_lbl_playerName.text = accountControl.LoggedInAccount.Username;
        ui_lbl_aiName.text     = ai_details.ai_name;
        //Assign the rewards the player recieved to the UI
        ui_lbl_rewards.text = rewardsText;
        //Output the Result to the UI
        if (hasPlayerLost)
        {
            ui_lbl_result.color = Color.red;
            ui_lbl_result.text  = "Result: Lost";
        }
        else
        {
            ui_lbl_result.color = Color.green;
            ui_lbl_result.text  = "Result: Win";
        }

        Destroy(duel_opponent);          //Dump the old Duel Opponent object
        //A new one is made at each new Duel, so it's okay
        //Stop the Duel music and go back to the MainMenu audio
        glob_audiomanager.SendMessage("StopDuelAudio");
        glob_audiomanager.SendMessage("PlayMainMenuAudio");
    }