public void Init(CommanderData data, List <TestMonster> listMonsters)
    {
        //가져온 데이터를 참조합니다
        this.data             = data;
        this.calculatedDamage = FormulaCalculator.GetInstance().AllCalculatedDamage_Commander(data.id);
        this.calculatedAspd   = FormulaCalculator.GetInstance().AllCalculatedAspd_Commander(data.id);

        if (this.animator == null)
        {
            this.animator = this.gameObject.GetComponentInChildren <Animator>();
        }

        //effectEvents를 초기화합니다
        this.effectEvents = this.GetComponentInChildren <EffectEvents>();
        //Debug.Log("============================");

        //Debug.Log(effectEvents);

        //boxCollider를 붙입니다(Hero Merge를 위함)
        this.boxCollider           = this.gameObject.AddComponent <BoxCollider>();
        this.boxCollider.size      = new Vector3(1, 3, 1);
        this.boxCollider.center    = new Vector3(0, 1.2f, 0);
        this.boxCollider.isTrigger = true;

        //몬스터 리스트 참조를 가져옵니다
        this.listMonsters = listMonsters;

        this.ChangeBehavior(eCommanderState.SEARCH);
    }
Example #2
0
 public void SetCommanderAttributes(CommanderData data)
 {
     //Data members
     this.commanderName = data.CharName;
     this.selectedCommanderPrefabPath = data.PrefabPath;
     this.hp                = data.HP;
     this.handSize          = data.CurrentHandSize;
     this.abilityChargeCost = data.AbilityChargeCost;
     this.abilityChargeType = data.AbilityChargeType;
     this.commanderData     = data;
     this.abilityTargetType = data.AbilityTargetType;
     this.manaPerTurn       = data.ManaPerTurn;
     Debug.Log("(2) SetCommanderAttributes called by " + data.CharName);
 }
Example #3
0
 public void SetCommanderAttributes(string name, GameObject prefab, string selectedCommanderPrefabPath, int startingHp, int startingHandSize, CommanderData cData, int playerId, int abilityChargeCost, GameConstants.CommanderAbilityTargetType abilityTargetType, int manaPerTurn)
 {
     //Data members
     this.commanderName               = name;
     this.commanderPrefab             = prefab;
     this.selectedCommanderPrefabPath = selectedCommanderPrefabPath;
     this.hp                = startingHp;
     this.handSize          = startingHandSize;
     this.playerId          = playerId;
     this.commanderData     = cData;
     this.abilityChargeCost = abilityChargeCost;
     this.abilityTargetType = abilityTargetType;
     this.manaPerTurn       = manaPerTurn;
 }
Example #4
0
    /// <summary>
    /// Creates Commander objects from the cached commander data on the global object.
    /// Also assigns the player ids to the newly created objects as part of the process and puts the sprites in their respective panels
    /// </summary>
    /// <returns></returns>
    public List <Commander> SetSelectedCommanderBattleImages()
    {
        List <Commander> commanders = new List <Commander>();

        Debug.Log("BATTLE UI MANAGER! ATTEMPTING TO SET COMMANDER IMAGES!!");
        /* Setting commander images for player 1 */

        //Get reference to player's commander data
        CommanderData playerCommanderData = GlobalObject.instance.humanPlayerCommanderData;
        CommanderData enemyCommanderData  = GlobalObject.instance.enemyCommanderData; //TODO: SHOULD this COME FROM THE MAP MANAGER

        //Load corresponding prefab based on path in the player's commander data
        GameObject playerCommanderPrefab = Resources.Load <GameObject>(playerCommanderData.PrefabPath);

        Debug.Log("BATTLE UI MANAGER: Prefab path is= " + playerCommanderData.PrefabPath);
        //Instantiate UI template object for player 1's commander
        GameObject playerCommanderInstance = Instantiate(playerCommanderPrefab) as GameObject;
        Commander  playerCommanderScript   = playerCommanderInstance.GetComponent <Commander>();

        playerCommanderScript.SetCommanderAttributes(playerCommanderData);
        playerCommanderScript.playerId = GameConstants.HUMAN_PLAYER_ID;
        commanders.Add(playerCommanderScript);

        //Parent newly created prefab to UI element for positioning
        playerCommanderInstance.transform.SetParent(GameObject.Find("PanelCommanderBattleP1/Image").transform, false);
        //NOTE! Had previously attempted to set the Commander UI panel variable reference in here for each commander but for some reason it ends up being null after Global Object gets the list back

        /*Setting commander images for player 2 (Enemy)*/
        GameObject enemyCommanderPrefab = Resources.Load <GameObject>(enemyCommanderData.PrefabPath);

        Debug.Log("BATTLE UI MANAGER: Prefab path is= " + enemyCommanderData.PrefabPath);
        //Instantiate UI template object for player 1's commander
        GameObject enemyCommanderInstance = Instantiate(enemyCommanderPrefab) as GameObject;
        Commander  enemyCommanderScript   = enemyCommanderInstance.GetComponent <Commander>();

        //Set the necessary data
        enemyCommanderScript.SetCommanderAttributes(enemyCommanderData);
        enemyCommanderScript.playerId = GameConstants.ENEMY_PLAYER_ID;
        commanders.Add(enemyCommanderScript);
        //Parent newly created prefab to UI element for positioning
        enemyCommanderInstance.transform.SetParent(GameObject.Find("PanelCommanderBattleP2/Image").transform, false);
        //flip sprite
        Transform enemyCommanderSprite = enemyCommanderInstance.transform.Find("Hero");

        enemyCommanderSprite.localScale = new Vector3(enemyCommanderSprite.transform.localScale.x * -1, enemyCommanderSprite.transform.localScale.y, enemyCommanderSprite.transform.localScale.z);
        Debug.LogWarning("BATTLE UI MANAGER! SetSelectedCommanderBattleImages called! passing back list of commanders with length: " + commanders.Count);
        return(commanders);
    }
Example #5
0
    void LoadCommanderSelectUI()
    {
        //Load commanders
        foreach (Commander c in GlobalObject.instance.loadedCommanders)
        {
            CommanderData cData = c.commanderData;
            /*Commented this out as deprecated*/
            //Rename object so instance name matches current commander
            //this.templateCommander.GetComponent<Commander>().name = cData.CharName+"Commander";


            GameObject commanderPrefab = Resources.Load <GameObject>(c.selectedCommanderPrefabPath);
            Debug.Log("GLOBAL OBJECT cData.PrefabPath is: " + c.selectedCommanderPrefabPath);
            //Instantiate empty template commander UI element
            GameObject listItem = GameObject.Instantiate(this.templateCommander) as GameObject;

            //commanderChildListItem.SetCommanderAttributes(cData.CharName, commanderPrefab, cData.PrefabPath, cData.MaxHP, cData.StartingHandSize, cData, GameConstants.HUMAN_PLAYER_ID, cData.AbilityChargeCost, cData.AbilityTargetType);
            //Add list item to scrollview UI
            listItem.transform.SetParent(GameObject.Find("CommanderSelectUIManager/CommanderSelectionScrollList/Viewport/Content/CommanderContainer").transform, false);
            //Create prefab to use as image on list item
            GameObject commanderGameObject = GameObject.Instantiate(commanderPrefab) as GameObject;
            commanderGameObject.transform.SetParent(listItem.transform.Find("Image").transform, false);

            //populate data for commander
            Commander commanderListItem = listItem.GetComponentInChildren <Commander>();//listItem.GetComponent<Commander>();

            //Set the value for all of these UI commanders player ID to be human player because any selected commander is used by the player
            commanderListItem.SetCommanderAttributes(
                cData.CharName,
                commanderPrefab,
                c.selectedCommanderPrefabPath,
                cData.MaxHP,
                cData.StartingHandSize,
                cData,
                GameConstants.HUMAN_PLAYER_ID,
                cData.AbilityChargeCost,
                cData.AbilityTargetType,
                cData.ManaPerTurn
                );
            //Set display name
            var nameTransform = listItem.transform.Find("header/Name");
            if (nameTransform && nameTransform != null)
            {
                nameTransform.GetComponent <Text>().text = cData.CharName;
            }
        }
    }
Example #6
0
 public void Invoke(string CurCmd, CommanderData Context)
 {
     IInnerCommander cmder = null;
     int iPos = 0;
     string Cmd = CurCmd;
     iPos = CurCmd.IndexOf('[');
     if (iPos != -1)//带参数
         Cmd = CurCmd.Substring(0, iPos);
     if (m_Commanders.ContainsKey(Cmd))
         cmder = m_Commanders[Cmd];
     else
         cmder = m_Commanders[string.Empty];
     cmder.Invoke(CurCmd, Context);
 }
Example #7
0
 public void Invoke(string CurCmd, CommanderData Context)
 {
     //默认情况下只运行程序配置的命令
     try
     {
         ProgFinder.FindToRun(CurCmd,false);
     }
     catch (ExtCommandLineBrokenException)//忽略扩展命令执行异常
     { }
 }
Example #8
0
        public void Invoke(string CurCmd, CommanderData Context)
        {
            if (!Context.Description.Equals(string.Empty))

                if (GlobalVar.Tip.Question("我要执行 " + Context.Description + " 咯", "待确认...")
               == System.Windows.Forms.DialogResult.No)
                    throw new ExtCommandLineBrokenException();
        }
Example #9
0
 public void Invoke(string CurCmd, CommanderData Context)
 {
     // System.Environment.
     //if (GlobalVar.MainForm != null)
     //    GlobalVar.MainForm.Dispose();
     MessageObj obj = new MessageObj("dispose", null);
     GlobalVar.Instanse.MsgPool.PushMessage(obj);
 }
Example #10
0
 public void Invoke(string CurCmd, CommanderData Context)
 {
     string sCmd = Context.ExtCmds;
     //取出命令
     if (!sCmd.Contains("[") || !sCmd.Contains("]"))
         throw new ExtCommandLineBrokenException();
     int iStart = sCmd.IndexOf('[');
     int iEnd = sCmd.LastIndexOf(']');
     string prog = sCmd.Substring(iStart + 1, iEnd - iStart - 1);
     //查找参数
     string path = FindPathByCmd(prog);
     Context.Args += " " + Context.ParsedCmd + " " + Context.Args;
     Context.ParsedCmd = path;
 }
Example #11
0
        public void Invoke(string CurCmd, CommanderData Context)
        {
            AppParamFrm frm = new AppParamFrm(Context);

            if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string param = frm.Param;
                Context.Args += " " + param;
            }
        }
Example #12
0
    void OnSceneLoaded(Scene scene, LoadSceneMode mode)
    {
        Debug.Log("Global object: Scene loaded! => name:" + scene.name + " index: " + scene.buildIndex.ToString());
        Debug.Log(mode.ToString());
        if (scene.buildIndex == GameConstants.SCENE_INDEX_COMMANDER_SELECT)
        {
            GlobalObject.instance.LoadCommanderSelectUI();
        }
        else if (SceneManager.GetActiveScene().buildIndex == GameConstants.SCENE_INDEX_GAME_COMMANDERS)
        {
            Debug.Log("GLOBAL OBJECT TRYING TO LOAD COMMANDER GAME SCENE!");
            //Try to find UI manager object for loading commander images
            GameObject battleUIManagerObj = GameObject.Find("LevelCanvas");
            GlobalObject.instance.battleUIManagerScript = battleUIManagerObj.GetComponent <BattleUIManager>();

            this.battleCommanders = new List <Commander>();

            //Trigger UI object to load commander images
            this.battleCommanders = GlobalObject.instance.battleUIManagerScript.SetSelectedCommanderBattleImages();

            //Set data attributes of the commanders
            CommanderData playerCommanderData = GlobalObject.instance.humanPlayerCommanderData;
            CommanderData enemyCommanderData  = GlobalObject.instance.enemyCommanderData;
            //Set mana per turn in the playfield from the commanders
            PlayField.instance.manaPerTurn   = playerCommanderData.ManaPerTurn;
            PlayField.instance.manaPerTurnAi = enemyCommanderData.ManaPerTurn;
            Debug.LogWarning("GlobalObject: setting mana per turn: " + PlayField.instance.manaPerTurn.ToString() + " and mana per turn AI is: " + PlayField.instance.manaPerTurnAi.ToString());
            //Iterate through list of commanders thrown back by the UI manager that set images
            for (int i = 0; i < battleCommanders.Count; i++)
            {
                Commander currCommander = battleCommanders[i];
                Debug.LogWarning("Global object! commanders index: " + i.ToString() + " and player id is:" + currCommander.playerId.ToString());
                //TODO: need unique conten ids or something better to match on here
                if (currCommander == null)
                {
                    Debug.LogWarning("CURR COMMANDER IS NULL!!!");
                }
                //Set player ids for the enemy commmander. We know it's not the player's if the player id is UNSET
                if (currCommander.playerId == GameConstants.UNSET_PLAYER_ID)
                {
                    currCommander.playerId = GameConstants.ENEMY_PLAYER_ID;
                    Debug.LogWarning("CURR COMMANDER HAS UNSET ID! SETTING TO ENEMY ID!");
                }
                //TODO: Fix bug here - matching off of commander name
                //if (currCommander.commanderData.CharName == playerCommanderData.CharName) {
                //    currCommander.playerId = GameConstants.HUMAN_PLAYER_ID;
                //} else if (currCommander.commanderData.CharName == enemyCommanderData.CharName) {
                //    currCommander.playerId = GameConstants.ENEMY_PLAYER_ID;
                //}
                //Set the rest of attributes
                currCommander.SetCommanderAttributes(currCommander.commanderData);
                //Set necessary UI references - not 100% sure why this didn't work when attempting to do so from within the BattleUIManager's SetSelectedCommanderBattleImages but for some reason results in a null ref if not set here
                GlobalObject.instance.battleUIManagerScript.SetCommanderUIPanel(ref currCommander);
                //Initialize some UI data to store variables and then set the display text for current charge and total cost
                currCommander.commanderUIPanel.Initialize(currCommander.playerId);
                currCommander.commanderUIPanel.SetCommanderResourceText(0, currCommander.abilityChargeCost);
                //Fire off notification for Commanders that the battle has started
                Debug.Log("SUHHHHHHHH************* " + currCommander.commanderName);
                currCommander.OnBattleStart();
            }

            //TODO: Need to change the logic for this at some point
        }
    }
Example #13
0
 /* Commander data code*/
 public void SetSelectedCommander(CommanderData cData)
 {
     this.humanPlayerCommanderData = cData;
 }