Exemple #1
0
    // Use this for initialization
    void Start()
    {
        // Using delayed invoke is not necessary, can change script execution order in Unity/Project Settings
        currentlyBattling = true;
        playerWon = false;
        enemyWon = false;
        paused = false;
        playerParticipate = true; // Set to true for testing
        unitsData = GameObject.Find("UnitsData");
        unitManager = unitsData.GetComponent<UnitManager>();
        gameManager = unitsData.GetComponent<GameManagers>();
        battleUI = GetComponent<BattleUI>();

        playerUnits = unitManager.getBattlingSquad();
        enemyUnits = unitManager.getEnemySquad(0); ////////////////////////  CHANGE MEEEEEEEEEEEEEEEEEEEEEEEE
    }
Exemple #2
0
 public void SetBattleUIDefault(BattleUI battleUI)
 {
     battleUI.SetDefaultUI(GetComponent <PlayerState>(), GetComponent <PlayerAttack>().GetCurrentWeapon());
 }
Exemple #3
0
 public static BattleUI _Initialze() {
     if (battleUI == null)
         battleUI = (BattleUI)FindObjectOfType(typeof(BattleUI));
     return battleUI;
 }
Exemple #4
0
 public void EnterNextWave()
 {
     if (BattleGlobals.liveMonsters.Count <= 0)//这波敌人死亡
     {
         BattleGlobals.isStop = true;
         if (BattleGlobals.currentWave < BattleGlobals.waves)//进入下一波
         {
             BattleGlobals.currentObj = null;
             BattleGlobals.otherObjs.Clear();
             foreach (Transform mp in GameObject.Find("mpoints").transform)
             {
                 foreach (Transform m in mp)
                 {
                     Destroy(m.gameObject);
                 }
             }
             //wave ui
             BattleGlobals.currentWave++;
             UIManager.ChangeText("waveText", "Battle " +
                                  BattleGlobals.currentWave.ToString() + "/" + BattleGlobals.waves.ToString());
             //create monsters
             Battle.currentMonsters = BattleGlobals.monsters[BattleGlobals.currentWave - 1];
             Battle.CreateCurrentEnemy();
             BattleUI.CreateHeads();
             //is boss
             if (BattleGlobals.currentWave == BattleGlobals.waves)
             {
                 BattleGlobals.isStop = true;
                 BattleUI.canvas.SetActive(false);
                 //boss(play boss bgm;hp slider;camera anim)
                 MusicManager.PlayBgm("boss");
                 BattleCamera.PlayAnim("_boss");
                 StartCoroutine(DelayToInvoke.DelayToInvokeDo(WaitNotStop, 6));
             }
             else
             {
                 StartCoroutine(DelayToInvoke.DelayToInvokeDo(WaitNotStop, 0.2f));
             }
         }
         else//win
         {
             BattleGlobals.isOver = true;
             BattleUI.HideUI();
             //if current hero else random(live heroes) -> set win bool true
             GameObject winObj  = null;
             Hero       winHero = null;
             if (BattleGlobals.currentObj.tag == "Hero")
             {
                 winObj = BattleGlobals.currentObj;
             }
             else
             {
                 winObj = BattleFuncs.FindObj
                              (BattleGlobals.liveHeroes[Random.Range(0, BattleGlobals.liveHeroes.Count - 1)]);
             }
             //camera
             string winIndex = winObj.transform.parent.gameObject.name
                               [winObj.transform.parent.gameObject.name.Length - 1].ToString();
             BattleCamera.SetAnimStop();
             BattleCamera.PlayAnim("h" + winIndex);
             winHero = BattleGlobals.currentObj.GetComponent <Hero>();
             winHero.Win();
             //show win ui(every select heroes exp++;date(attribute) ++;click->return select map)
             StartCoroutine(DelayToInvoke.DelayToInvokeDo(WaitShowWin, 4f));
         }
     }
     if (BattleGlobals.liveHeroes.Count <= 0)//英雄全部死亡,失败
     {
         BattleGlobals.isOver = true;
         BattleGlobals.isStop = true;
         BattleUI.HideUI();
         //show lose ui(click->return select map)
         BattleUI.ShowLosePanel();
     }
 }
Exemple #5
0
 public BattleCoroutines(BattleUI display)
 {
     DISPLAY        = display;
     animationsOver = true;
     AnimationQueue = new List <IEnumerator>();
 }
Exemple #6
0
 // Use this for initialization
 void Start()
 {
     button = GetComponent <BattleUI>();
     player = GetComponent <PlayerStatus>();
 }
Exemple #7
0
    //Private Methods
    private void Init(BattleInfo battleInfo)
    {
        if (Application.isMobilePlatform)
        {
            Screen.sleepTimeout = SleepTimeout.NeverSleep;
        }

        DivineDebug.Log("Initing battle Logic.");

        _curState    = BattleLogicStates.Start;
        _battleInfo  = battleInfo;
        _battleScene = BattleSceneManager.instance.SelectBattleScene(_battleInfo.battleSceneType);
        _newBattleUI = NewUIGroup.CreateGroup(NewUIGroup.NAME__BATTLEUI, NewUIGroup.PrefabProviderType.Battle) as BattleUI;

        _generatedApOnDeath     = AppManager.instance.config.apDeath;
        _generatedApDamageTaken = AppManager.instance.config.apTakenDamage;

        _isFirstTurn   = true;
        _battleEndCame = false;

        _firstPing         = true;
        _pingProblem       = AppManager.instance.config.pingProblemNumber;
        _timeOutTime       = _pingProblem * 5;
        _clientCurrentTime = Time.time;

        _currentselectedCharacters = new List <Character>();

        MakeParties(_battleInfo.partyInfoes);
        StartParties();

        List <Character> orderArray = new List <Character>(_battleInfo.charactersTurnOrder_id.Length);

        foreach (var item in _battleInfo.charactersTurnOrder_id)
        {
            var characterOrder = _parties[0].FindCharacter(item);

            if (characterOrder != null)
            {
                orderArray.Add(characterOrder);
            }
            else
            {
                orderArray.Add(_parties[1].FindCharacter(item));
            }
        }

        _newBattleUI.Init(_parties[0].Name, _parties[1].Name,
                          _battleInfo.turnTime,
                          battleInfo.partyInfoes[0].availableSecrets,
                          OnSpellSelectedByCurrentChar,
                          OnSecretSelected,
                          orderArray);

        _newBattleUI.InitScore(0, 0);

        BattleDataProvider.instance.SetBattleLogic(this);

        BattleDataProvider.instance.Event_BattleFinish   += OnBattleFinishedComeFromServer;
        BattleDataProvider.instance.Event_BattleTurnData += OnTurnChanged;
        BattleDataProvider.instance.Event_ActionReceived += OnActionReceived;
        BattleDataProvider.instance.Event_BattlePingTick += OnPinging;
        //BattleDataProvider.instance.Event_Secret += OnSecretCastSuccessful;

        if (!TutorialManager.instance.IsInBattleTutorial())
        {
            TimeManager.instance.Event_OneSecTick += OnSecTick;
        }

        _battleSpellDataProvider = BattleSpellDataProvider.instance;

        GameAnalytics.NewProgressionEvent(GAProgressionStatus.Start, _parties[0].hero.moniker.ToString());

        if (_battleInfo.isBot)
        {
            _botLogic = new BotLogic(orderArray, battleInfo.botPower);
        }

        //Test
        FakeServer.instance.Event_ActionAnalyzed += OnActionReceived;
        FakeServer.instance.Event_BattleFinished += OnBattleFinishedComeFromServer;
    }
Exemple #8
0
 public BattlePhase(BattleUI ui, BattleField field, string callback) : base(TurnPhase.BATTLE, callback)
 {
     this._ui    = ui;
     this._field = field;
     Messenger.AddListener <FightResult>(Messages.OnFightEnd, this.OnFightEnd);
 }
Exemple #9
0
 public TurnStartPhase(BattleField field, BattleUI ui, string callback) : base(TurnPhase.TURN_START, callback)
 {
     this._field = field;
     this._ui    = ui;
 }
Exemple #10
0
 /// <summary>
 /// Used by the BattleManager class to assign itself to the parties bm variable
 /// </summary>
 /// <param name="manager"></param>
 public void SetBattleManager(BattleManager manager, BattleUI bui, BoardManager brd)
 {
     bm    = manager;
     ui    = bui;
     board = brd;
 }
 public void OnUILoadFinish(BattleUI battleUI)
 {
     this.ui = battleUI;
 }
Exemple #12
0
 public void Init(BattleUI battle)
 {
     this.battle = battle;
 }
Exemple #13
0
        public static BattleUI InitiateCombatUI(int phase)
        {
            /*
             * 1 - Kira, Aiden ... bandit 3
             * 2 - Aiden ... bandit 2
             * 3 - Kira .. bandit 1
             * 4 - Kira, Aiden ... bandit 1 2 3
             * 5 - Kira, Aiden ... bear
             */
            //Console.WriteLine(phase.ToString());
            CharacterStates[] arrHeroes;
            CharacterStates[] arrEnemies;
            if (phase == 1)
            {
                //create our characters
                arrHeroes = new CharacterStates[2] {
                    new CharacterStates((int)officerDictionary.AIDEN),
                    new CharacterStates((int)officerDictionary.KIRA)
                };
                //create our enemies
                arrEnemies = new CharacterStates[3] {
                    new CharacterStates((int)officerDictionary.BANDIT2),
                    new CharacterStates((int)officerDictionary.BANDIT3),
                    new CharacterStates((int)officerDictionary.BANDIT1)
                };
            }
            else if (phase == 2)
            {
                //create our characters
                arrHeroes = new CharacterStates[2] {
                    new CharacterStates((int)officerDictionary.AIDEN),
                    new CharacterStates((int)officerDictionary.KIRA)
                };
                //create our enemies
                arrEnemies = new CharacterStates[3] {
                    new CharacterStates((int)officerDictionary.BANDIT3),
                    new CharacterStates((int)officerDictionary.BANDIT2),
                    new CharacterStates((int)officerDictionary.BANDIT1)
                };
            }
            else if (phase == 3)
            {
                //create our characters
                arrHeroes = new CharacterStates[2] {
                    new CharacterStates((int)officerDictionary.AIDEN),
                    new CharacterStates((int)officerDictionary.KIRA)
                };
                //create our enemies
                arrEnemies = new CharacterStates[3] {
                    new CharacterStates((int)officerDictionary.BANDIT3),
                    new CharacterStates((int)officerDictionary.BANDIT1),
                    new CharacterStates((int)officerDictionary.BANDIT2),
                };
            }
            else if (phase == 4)
            {
                //create our characters
                arrHeroes = new CharacterStates[2] {
                    new CharacterStates((int)officerDictionary.AIDEN),
                    new CharacterStates((int)officerDictionary.KIRA)
                };
                //create our enemies
                arrEnemies = new CharacterStates[3] {
                    new CharacterStates((int)officerDictionary.BANDIT1),
                    new CharacterStates((int)officerDictionary.BANDIT2),
                    new CharacterStates((int)officerDictionary.BANDIT3)
                };
            }
            else
            {
                //create our characters
                arrHeroes = new CharacterStates[2] {
                    new CharacterStates((int)officerDictionary.AIDEN),
                    new CharacterStates((int)officerDictionary.KIRA)
                };
                //create our enemies
                arrEnemies = new CharacterStates[3] {
                    new CharacterStates((int)officerDictionary.BANDIT1),
                    new CharacterStates((int)officerDictionary.BEAR),
                    new CharacterStates((int)officerDictionary.BANDIT3)
                };
            }


            BattleUI scene = new BattleUI(arrHeroes, arrEnemies, phase);

            //BattleUI.BattleStarted = true;
            return(scene);
        }
Exemple #14
0
    private void _Move(string dir, int sign)
    {
        //Deal with indexing errors by checking len of cell array.
        //When going up or down on the stick just go in the y then z.

        prev_coords = coords;

        int prev_coord_x = coords.X_coord;
        int prev_coord_z = coords.Z_coord;

        if (dir.Equals("z"))
        {
            coords.z += sign;
        }

        if (dir.Equals("x"))
        {
            coords.x += sign;
        }

        if (dir.Equals("y"))
        {
            coords.x -= sign;
            coords.z += sign;
        }

        HexagonCoord next_cell;
        HexagonCell  next_hex_cell;

        try
        {
            next_cell     = _Grid.Get_Cell_Index(coords).coords;
            next_hex_cell = _Grid.Get_Cell_Index(coords);

            if (coords.X_coord == next_cell.X_coord && coords.Z_coord == next_cell.Z_coord)
            {
                //It found a real tile.
                if (editor.isUnitSelected)
                {
                    if (next_hex_cell.distance <= editor.SelectedUnit.current_mobility)
                    {
                        gameObject.transform.position = _Grid.Get_Cell_Index(coords).gameObject.transform.position;
                        Move_Sound.Play();
                    }
                    else
                    {
                        coords.x = prev_coord_x;
                        coords.z = prev_coord_z;
                    }
                }
                else
                {
                    gameObject.transform.position = _Grid.Get_Cell_Index(coords).gameObject.transform.position;
                    Move_Sound.Play();
                }
            }
            else
            {
                //It found a not-real tile. Revert Change.
                coords.x = prev_coord_x;
                coords.z = prev_coord_z;
            }
        }
        catch (System.IndexOutOfRangeException e)
        {
            coords.x = prev_coord_x;
            coords.z = prev_coord_z;
            Debug.Log(e.Message);
        }


        if (editor.isUnitSelected)
        {
            editor.Show_Units_In_Range();
            //add to if statement if you dont want the same unit to pop up in both
            //&& editor.SelectedUnit != _Grid.Get_Cell_Index(coords).unitOnTile
            if (_Grid.Get_Cell_Index(coords).unitOnTile != null)
            {
                //if(editor.allow_cursor_control)
                StartUnit _tileUnit = _Grid.Get_Cell_Index(coords).unitOnTile;

                BattleUI _tileUnit_UI = _tileUnit.Unit_Stats_Panel.GetComponent <BattleUI>();
                editor.Assign_Stats_Var(_tileUnit_UI, _tileUnit);
                _tileUnit_UI.Show();
            }
        }
        else
        {
            if (_Grid.Get_Cell_Index(coords).unitOnTile != null)
            {
                StartUnit _tileUnit = _Grid.Get_Cell_Index(coords).unitOnTile;

                BattleUI _tileUnit_UI = _tileUnit.Unit_Stats_Panel.GetComponent <BattleUI>();
                editor.Assign_Stats_Var(_tileUnit_UI, _tileUnit);
                _tileUnit_UI.Show();
            }
        }

        Hide_Prev_UI();

        Order_Cursor(_Grid.GetCell(transform.position).coords, _Grid.sprites_per_tile);

        //deal with UI_List_Manager On Move
        UI_List_Manager.update_current_controls();

        //Debug.Log("Current X " + coords.X_coord);
        //Debug.Log("Current Y " + coords.Y_coord);
        //Debug.Log("Current Z " + coords.Z_coord);
        //Debug.Log(_Grid.Get_Cell_Index(coords).gameObject.transform.position);
    }
Exemple #15
0
 private void Start()
 {
     defaultUI();
     settingHomeUI = GetComponentInChildren <SettingHomeUI>();
     battleUI      = GetComponentInChildren <BattleUI>();
 }
 void Awake()
 {
     m_Instance = this;
 }
Exemple #17
0
 void Awake()
 {
     Instance = this;
 }
    public void SpecialInit(Action winCallback, Action loseCallback) //特殊場景的 Init
    {
        BattlefieldGenerator.Instance.GenerateFromTilemap(BattlefieldId);

        Turn          = 1;
        _power        = TeamManager.Instance.Power;
        _exp          = Exp;
        _winCallback  = winCallback;
        _loseCallback = loseCallback;
        CharacterList.Clear();

        BattleCharacter character;

        TeamMember        member;
        List <TeamMember> memberList = TeamManager.Instance.GetAttendList();

        for (int i = 0; i < memberList.Count; i++)
        {
            member         = memberList[i];
            character      = ResourceManager.Instance.Spawn("BattleCharacter/BattleCharacter", ResourceManager.Type.Other).GetComponent <BattleCharacter>();
            character.name = member.Data.Animator;
            character.Init(member, TeamManager.Instance.Lv);
            CharacterList.Add(character);
            _playerList.Add(character);
            character.SetPosition((Vector2)(member.Formation + BattleFieldManager.Instance.Center));

            if (character.LiveState == BattleCharacter.LiveStateEnum.Dead)
            {
                character.Sprite.color = Color.clear;
            }
        }

        EnemyData.RootObject data;
        List <int>           itemList = new List <int>(); //單隻怪的掉落物

        for (int i = 0; i < Enemys.Length; i++)
        {
            character = Enemys[i];
            character.InitByInspector();
            CharacterList.Add(character);

            data     = character.Info.EnemyData;
            itemList = data.GetDropItemList();
            for (int j = 0; j < itemList.Count; j++)
            {
                _dropItemList.Add(itemList[j]);
            }
        }

        int itemId;

        ItemData.RootObject  itemData;
        SkillData.RootObject skillData;
        Skill       skill;
        List <Item> medicineList = ItemManager.Instance.GetItemListByType(ItemManager.Type.Bag, ItemData.TypeEnum.Medicine);

        if (medicineList != null)
        {
            foreach (Item item in medicineList)
            {
                itemId       = item.ID;
                itemData     = ItemData.GetData(itemId);
                skillData    = SkillData.GetData(itemData.Skill);
                skill        = SkillFactory.GetNewSkill(skillData, null, 1);
                skill.ItemID = itemId;
                ItemSkillList.Add(skill);
            }
        }

        Camera.main.transform.position = new Vector3(BattleFieldManager.Instance.Center.x, BattleFieldManager.Instance.Center.y, Camera.main.transform.position.z);
        AudioSystem.Instance.Play("Battle", true);
        ChangeSceneUI.Instance.EndClock(() =>
        {
            BattleUI.Open();
            BattleUI.Instance.Init(_power, CharacterList, false);

            if (InitHandler != null)
            {
                InitHandler();
            }

            ChangeState <TurnStartState>();
        });
    }
Exemple #19
0
 private void OnBattleLoaded(Scene scene, LoadSceneMode mode)
 {
     _battleUI = FindObjectOfType <BattleUI>();
     _battleUI.gameObject.SetActive(false);
 }
    private List <BattleCharacter> _playerList  = new List <BattleCharacter>(); //戰鬥結束時需要的友方資料

    public void Init(int battlefieldId, BattleGroupData.RootObject battleGroupData, Action winCallback, Action loseCallback)
    {
        BattlefieldGenerator.Instance.Generate(battlefieldId, battleGroupData.EnemyList.Count);

        Turn          = 1;
        _power        = TeamManager.Instance.Power;
        _exp          = battleGroupData.Exp;
        _winCallback  = winCallback;
        _loseCallback = loseCallback;
        CharacterList.Clear();

        BattleCharacter character;

        TeamMember        member;
        List <TeamMember> memberList = TeamManager.Instance.GetAttendList();

        for (int i = 0; i < memberList.Count; i++)
        {
            member         = memberList[i];
            character      = ResourceManager.Instance.Spawn("BattleCharacter/BattleCharacter", ResourceManager.Type.Other).GetComponent <BattleCharacter>();
            character.name = member.Data.Animator;
            character.Init(member, TeamManager.Instance.Lv);
            CharacterList.Add(character);
            _playerList.Add(character);
            character.SetPosition((Vector2)(member.Formation + BattleFieldManager.Instance.Center));

            if (character.LiveState == BattleCharacter.LiveStateEnum.Dead)
            {
                character.Sprite.color = Color.clear;
            }
        }

        EnemyData.RootObject            data;
        List <int>                      itemList  = new List <int>(); //單隻怪的掉落物
        List <KeyValuePair <int, int> > enemyList = battleGroupData.GetEnemy();

        for (int i = 0; i < enemyList.Count; i++)
        {
            data     = EnemyData.GetData(enemyList[i].Key);
            itemList = data.GetDropItemList();
            for (int j = 0; j < itemList.Count; j++)
            {
                _dropItemList.Add(itemList[j]);
            }
            character = ResourceManager.Instance.Spawn("BattleCharacter/BattleCharacter", ResourceManager.Type.Other).GetComponent <BattleCharacter>();
            character.Init(enemyList[i].Key, enemyList[i].Value);
            CharacterList.Add(character);
            character.SetPosition(BattleFieldManager.Instance.EnemyPositionList[i]);
        }

        int itemId;

        ItemData.RootObject  itemData;
        SkillData.RootObject skillData;
        Skill       skill;
        List <Item> medicineList = ItemManager.Instance.GetItemListByType(ItemManager.Type.Bag, ItemData.TypeEnum.Medicine);

        if (medicineList != null)
        {
            foreach (Item item in medicineList)
            {
                itemId       = item.ID;
                itemData     = ItemData.GetData(itemId);
                skillData    = SkillData.GetData(itemData.Skill);
                skill        = SkillFactory.GetNewSkill(skillData, null, 1);
                skill.ItemID = itemId;
                ItemSkillList.Add(skill);
            }
        }

        Camera.main.transform.position = new Vector3(BattleFieldManager.Instance.Center.x, BattleFieldManager.Instance.Center.y, Camera.main.transform.position.z);
        AudioSystem.Instance.Play("Battle", true);
        ChangeSceneUI.Instance.EndClock(() =>
        {
            BattleUI.Open();
            BattleUI.Instance.Init(_power, CharacterList, battleGroupData.CanEscape);
            ChangeState <TurnStartState>();
        });
    }
Exemple #21
0
 void WaitShowWin()
 {
     BattleUI.ShowWinPanel();
 }
Exemple #22
0
 public BattleFight(BattleField field, FightingEntity fighter, QueuedAction action, BattleUI ui)
 {
     this._field       = field;
     this.fighter      = fighter;
     this.queuedAction = action;
     this._ui          = ui;
 }
 public override void startMatch(Match match)
 {
     base.startMatch(match);
     ui = GameObject.FindObjectOfType<BattleUI>();
     ui.Show(this);
 }
Exemple #24
0
 void Start()
 {
     battleUI = FindObjectOfType <BattleUI>();
 }