Exemplo n.º 1
0
    void ChooseAction()
    {
        BattleTurn myAttack = new BattleTurn();

        myAttack.AttackerName = enemy.name;
        myAttack.Attacker     = this.gameObject;
        myAttack.Defender     = BSM.Heros[Random.Range(0, BSM.Heros.Count)];
        myAttack.Type         = "Enemy";
        BSM.GatherActions(myAttack);
    }
Exemplo n.º 2
0
        public BattleManager(IPlayerSystem playerSystem
                             , IOpponentSystem opponentSystem
                             , ICameraController cameraController)
        {
            this.playerSystem     = playerSystem;
            this.opponentSystem   = opponentSystem;
            this.cameraController = cameraController;

            BattleTurn = BattleTurn.Player;
        }
Exemplo n.º 3
0
        public void SetTurn(BattleTurn battleTurn)
        {
            this.BattleTurn = battleTurn;

            if (this.BattleTurn == BattleTurn.Player)
            {
                cameraController.Target = playerSystem.GetPlayer().transform;
            }

            if (this.BattleTurn == BattleTurn.Opponent)
            {
                cameraController.Target = opponentSystem.GetOpponent().transform;
            }
        }
Exemplo n.º 4
0
 public void ChangeTurn()
 {
     if (CurrentTurn == BattleTurn.Player)
     {
         PlayerTurnCursor.gameObject.SetActive(false);
         MonsterTurnCursor.gameObject.SetActive(true);
         CurrentTurn      = BattleTurn.Monster;
         IsCompletingTurn = true;
         Monster.ClearBuffs();
         Monster.PerformBattleAction();
     }
     else
     {
         PlayerTurnCursor.gameObject.SetActive(true);
         MonsterTurnCursor.gameObject.SetActive(false);
         CurrentTurn = BattleTurn.Player;
         Monster.SetNextMove();
         Player.ClearBuffs();
         Deck.DraftCard();
     }
 }
Exemplo n.º 5
0
        public void SetLastBattleData(DataBattle data)
        {
            Debug.LogWarning("!!!!!!!!!!!!!!!!!!!!!! SetLastBattleData() !!!!!!!!!!!!!!!!!!!!!!");
            string dlog = "missionID = " + data.MissionID;

            dlog += ",\t\t roundCount = " + data.Round_count;
            dlog += ",\t\t Win_idx = " + data.Win_idx;
            Debug.LogWarning(dlog);
            ClearBattleData();//clear first
            missionID    = (int)data.MissionID;
            roundCount   = data.Round_count;
            isPlayed     = false;
            isLastBattle = true;
            isWin        = !Convert.ToBoolean(data.Win_idx);
            foreach (xjgame.message.DropBag bag in data.dropsList)
            {
                DropBag drop_bag = new DropBag();
                drop_bag.type = (DropType)bag.Type;
                drop_bag.val  = bag.Value;
                winDropBags.Add(drop_bag);
            }
            addExp = data.Add_exp;
            //test
            if (Obj_MyselfPlayer.GetMe().currentAssistFriend == null)
            {
                Obj_MyselfPlayer.GetMe().currentAssistFriend = new AssistFriend();
                Obj_MyselfPlayer.GetMe().currentAssistFriend.guid = (long)data.Friendguid;
                Obj_MyselfPlayer.GetMe().currentAssistFriend.name = data.Friendname;
                Obj_MyselfPlayer.GetMe().currentAssistFriend.level = data.Friendlevel;
                Obj_MyselfPlayer.GetMe().currentAssistFriend.cardLevel = data.FriendCardLev;
                Obj_MyselfPlayer.GetMe().currentAssistFriend.friendShipNum = data.GetFriendPoint;
                if (data.IsFriend == 0)
                {
                    Obj_MyselfPlayer.GetMe().currentAssistFriend.isMyFriend = true;
                }
                else
                {
                    Obj_MyselfPlayer.GetMe().currentAssistFriend.isMyFriend = false;
                }
            }
            foreach (xjgame.message.BattleCard card in data.userCardList)
            {
                string log = "Card: slot_idx = " + card.Place_idx + ",\t\t cardid = " + card.CardID + ",\t\t guid = " + card.Cardguid;
                log += ",\t\t state = " + card.State;
                log += ",\t\t isfriend = " + card.Isfriend;
                log += ",\t\t commSkillID = " + card.CommSkillId;
                log += ",\t\t volSkillID = " + card.VolSkillId;
                log += ",\t\t combSkillID = " + card.CombSkillId;

                if (card.Place_idx < 6)
                {
                    TroopMember member = new TroopMember(card.Place_idx, card.CardID, (long)card.Cardguid);
                    member.state       = card.State;
                    member.initHp      = card.Init_hp;
                    member.commSkillID = card.CommSkillId;
                    member.volSkillID  = card.VolSkillId;
                    member.combSkillID = card.CombSkillId;
                    if (card.Bag != null)
                    {
                        member.bag.type = (DropType)card.Bag.Type;
                        member.bag.val  = card.Bag.Value;
                        log            += ",\t\t DropBag.Type = " + card.Bag.Type;
                        log            += ",\t\t DropBag.Value = " + card.Bag.Value;
                    }
                    troopData.selfMembers.Add(member);
                    if (card.Isfriend == 1)
                    {
                        Obj_MyselfPlayer.GetMe().currentAssistFriend.cardGuiId = (long)card.Cardguid;
                        Obj_MyselfPlayer.GetMe().currentAssistFriend.cardTempleId = card.CardID;
                        Obj_MyselfPlayer.GetMe().battleArray[card.Place_idx] = (long)card.Cardguid;
                    }
                }
                else
                {
                    TroopMember member = new TroopMember(card.Place_idx, card.CardID, (long)card.Cardguid);
                    member.state       = card.State;
                    member.initHp      = card.Init_hp;
                    member.commSkillID = card.CommSkillId;
                    member.volSkillID  = card.VolSkillId;
                    member.combSkillID = card.CombSkillId;
                    if (card.Bag != null)
                    {
                        member.bag.type = (DropType)card.Bag.Type;
                        member.bag.val  = card.Bag.Value;
                        log            += ",\t\t DropBag.Type = " + card.Bag.Type;
                        log            += ",\t\t DropBag.Value = " + card.Bag.Value;
                    }
                    troopData.otherMembers.Add(member);
                }
                Debug.LogWarning(log);
            }

            foreach (DataRound round in data.roundsList)
            {
                BattleTurn turn = new BattleTurn();
                foreach (DataAction action in round.actionsList)
                {
                    BattleStep step = new BattleStep();
                    foreach (DataSingleAction sact in action.attacker_actionsList)
                    {
                        string log = "Attack action: ";
                        log += ",\t\t card_idx = " + sact.Card_idx;
                        log += ",\t\t skillid = " + sact.Skillid;
                        log += ",\t\t att_value = " + sact.Att_value;
                        log += ",\t\t att_type = " + sact.Att_type;
                        log += ",\t\t beCrit = " + sact.BeCrit;
                        log += ",\t\t cur_hp = " + sact.Cur_hp;
                        log += ",\t\t heti_idx = " + sact.Heti_idx;

                        StepAction attack = new StepAction();
                        if (sact.buffInfoList != null)
                        {
                            foreach (DataBuffInfo buf in sact.buffInfoList)
                            {
                                BuffInfo attBuf = new BuffInfo();
                                attBuf.buf_id    = buf.Buf_id;
                                attBuf.buf_value = buf.Buf_value;
                                attack.buff.Add(attBuf);
                                log += ",\t\t buf.Buf_id = " + buf.Buf_id;
                                log += ",\t\t buf.Buf_value = " + buf.Buf_value;
                            }
                        }
                        attack.slotIndex = sact.Card_idx;
                        attack.skillID   = sact.Skillid;
                        attack.attackHp  = sact.Att_value;
                        attack.harmType  = sact.Att_type;
                        attack.isStorm   = Convert.ToBoolean(sact.BeCrit);
                        attack.curHp     = sact.Cur_hp;
                        if (sact.HasHeti_idx)
                        {
                            attack.hetiIndex = sact.Heti_idx;
                        }
                        step.attacks.Add(attack);
                        Debug.LogWarning(log);
                    }

                    foreach (DataSingleAction sact in action.be_attacker_actionsList)
                    {
                        string log = "Behit action: ";
                        log += ",\t\t card_idx = " + sact.Card_idx;
                        log += ",\t\t skillid = " + sact.Skillid;
                        log += ",\t\t att_value = " + sact.Att_value;
                        log += ",\t\t att_type = " + sact.Att_type;
                        log += ",\t\t beCrit = " + sact.BeCrit;
                        log += ",\t\t cur_hp = " + sact.Cur_hp;
                        log += ",\t\t heti_idx = " + sact.Heti_idx;

                        StepAction behit = new StepAction();
                        if (sact.buffInfoList != null)
                        {
                            foreach (DataBuffInfo buf in sact.buffInfoList)
                            {
                                BuffInfo behitBuf = new BuffInfo();
                                behitBuf.buf_id    = buf.Buf_id;
                                behitBuf.buf_value = buf.Buf_value;
                                behit.buff.Add(behitBuf);
                                log += ",\t\t buf.Buf_id = " + buf.Buf_id;
                                log += ",\t\t buf.Buf_value = " + buf.Buf_value;
                            }
                        }
                        behit.slotIndex = sact.Card_idx;
                        behit.skillID   = sact.Skillid;
                        behit.attackHp  = sact.Att_value;
                        behit.harmType  = sact.Att_type;
                        behit.isStorm   = Convert.ToBoolean(sact.BeCrit);
                        behit.curHp     = sact.Cur_hp;
                        step.behits.Add(behit);
                        Debug.LogWarning(log);
                    }
                    turn.battleSteps.Add(step);
                }
                battleRound.battleTurns.Add(turn);
            }
            Obj_MyselfPlayer.GetMe().SetBattleBeforeDate();
        }
Exemplo n.º 6
0
        public void SetPVPBattleData(SCPVPBattleData data)
        {
            ClearBattleData();//clear first

            //pb data
            pbBaseData = data.BaseData;
            pbBagData  = data.BagData;
            pbCopyData = data.CopyData;

            isPlayed     = false;
            isLastBattle = false;
            isWin        = !Convert.ToBoolean(data.Battle.Win_idx);
            foreach (xjgame.message.DropBag bag in data.Battle.dropsList)
            {
                DropBag drop_bag = new DropBag();
                drop_bag.type = (DropType)bag.Type;
                drop_bag.val  = bag.Value;
                winDropBags.Add(drop_bag);
            }
            addExp = data.Battle.Add_exp;

            Debug.LogWarning("!!!!!!!!!!!!!!!!!!!!!! SetPVPBattleData() !!!!!!!!!!!!!!!!!!!!!!");
            foreach (xjgame.message.BattleCard card in data.Battle.userCardList)
            {
                string log = "Card: slot_idx = " + card.Place_idx + ",\t\t cardid = " + card.CardID + ",\t\t guid = " + card.Cardguid;
                log += ",\t\t state = " + card.State;
                log += ",\t\t commSkillID = " + card.CommSkillId;
                log += ",\t\t volSkillID = " + card.VolSkillId;
                log += ",\t\t combSkillID = " + card.CombSkillId;

                if (card.Place_idx < 6)
                {
                    TroopMember member = new TroopMember(card.Place_idx, card.CardID, (long)card.Cardguid);
                    member.state       = card.State;
                    member.initHp      = card.Init_hp;
                    member.commSkillID = card.CommSkillId;
                    member.volSkillID  = card.VolSkillId;
                    member.combSkillID = card.CombSkillId;
                    if (card.Bag != null)
                    {
                        member.bag.type = (DropType)card.Bag.Type;
                        member.bag.val  = card.Bag.Value;
                        log            += ",\t\t DropBag.Type = " + card.Bag.Type;
                        log            += ",\t\t DropBag.Value = " + card.Bag.Value;
                    }
                    troopData.selfMembers.Add(member);
                }
                else
                {
                    TroopMember member = new TroopMember(card.Place_idx, card.CardID, (long)card.Cardguid);
                    member.state       = card.State;
                    member.initHp      = card.Init_hp;
                    member.commSkillID = card.CommSkillId;
                    member.volSkillID  = card.VolSkillId;
                    member.combSkillID = card.CombSkillId;
                    if (card.Bag != null)
                    {
                        member.bag.type = (DropType)card.Bag.Type;
                        member.bag.val  = card.Bag.Value;
                        log            += ",\t\t DropBag.Type = " + card.Bag.Type;
                        log            += ",\t\t DropBag.Value = " + card.Bag.Value;
                    }
                    troopData.otherMembers.Add(member);
                }
                Debug.LogWarning(log);
            }

            foreach (DataRound round in data.Battle.roundsList)
            {
                BattleTurn turn = new BattleTurn();
                foreach (DataAction action in round.actionsList)
                {
                    BattleStep step = new BattleStep();
                    foreach (DataSingleAction sact in action.attacker_actionsList)
                    {
                        string log = "Attack action: ";
                        log += ",\t\t card_idx = " + sact.Card_idx;
                        log += ",\t\t skillid = " + sact.Skillid;
                        log += ",\t\t att_value = " + sact.Att_value;
                        log += ",\t\t att_type = " + sact.Att_type;
                        log += ",\t\t beCrit = " + sact.BeCrit;
                        log += ",\t\t cur_hp = " + sact.Cur_hp;
                        log += ",\t\t heti_idx = " + sact.Heti_idx;

                        StepAction attack = new StepAction();
                        if (sact.buffInfoList != null)
                        {
                            foreach (DataBuffInfo buf in sact.buffInfoList)
                            {
                                BuffInfo attBuf = new BuffInfo();
                                attBuf.buf_id    = buf.Buf_id;
                                attBuf.buf_value = buf.Buf_value;
                                attack.buff.Add(attBuf);
                                log += ",\t\t buf.Buf_id = " + buf.Buf_id;
                                log += ",\t\t buf.Buf_value = " + buf.Buf_value;
                            }
                        }
                        attack.slotIndex = sact.Card_idx;
                        attack.skillID   = sact.Skillid;
                        attack.attackHp  = sact.Att_value;
                        attack.harmType  = sact.Att_type;
                        attack.isStorm   = Convert.ToBoolean(sact.BeCrit);
                        attack.curHp     = sact.Cur_hp;
                        if (sact.HasHeti_idx)
                        {
                            attack.hetiIndex = sact.Heti_idx;
                        }
                        step.attacks.Add(attack);
                        Debug.LogWarning(log);
                    }

                    foreach (DataSingleAction sact in action.be_attacker_actionsList)
                    {
                        string log = "Behit action: ";
                        log += ",\t\t card_idx = " + sact.Card_idx;
                        log += ",\t\t skillid = " + sact.Skillid;
                        log += ",\t\t att_value = " + sact.Att_value;
                        log += ",\t\t att_type = " + sact.Att_type;
                        log += ",\t\t beCrit = " + sact.BeCrit;
                        log += ",\t\t cur_hp = " + sact.Cur_hp;
                        log += ",\t\t heti_idx = " + sact.Heti_idx;

                        StepAction behit = new StepAction();
                        if (sact.buffInfoList != null)
                        {
                            foreach (DataBuffInfo buf in sact.buffInfoList)
                            {
                                BuffInfo behitBuf = new BuffInfo();
                                behitBuf.buf_id    = buf.Buf_id;
                                behitBuf.buf_value = buf.Buf_value;
                                behit.buff.Add(behitBuf);
                                log += ",\t\t buf.Buf_id = " + buf.Buf_id;
                                log += ",\t\t buf.Buf_value = " + buf.Buf_value;
                            }
                        }
                        behit.slotIndex = sact.Card_idx;
                        behit.skillID   = sact.Skillid;
                        behit.attackHp  = sact.Att_value;
                        behit.harmType  = sact.Att_type;
                        behit.isStorm   = Convert.ToBoolean(sact.BeCrit);
                        behit.curHp     = sact.Cur_hp;
                        step.behits.Add(behit);
                        Debug.LogWarning(log);
                    }
                    turn.battleSteps.Add(step);
                }
                battleRound.battleTurns.Add(turn);
            }
        }
Exemplo n.º 7
0
        private void SetDataRound(IList <DataRound> dataRound)
        {
            foreach (DataRound round in dataRound)
            {
                BattleTurn turn = new BattleTurn();
                foreach (DataAction action in round.actionsList)
                {
                    BattleStep step = new BattleStep();
                    foreach (DataSingleAction sact in action.attacker_actionsList)
                    {
                        string log = "Attack action: ";
                        log += ",\t\t card_idx = " + sact.Card_idx;
                        log += ",\t\t skillid = " + sact.Skillid;
                        log += ",\t\t att_value = " + sact.Att_value;
                        log += ",\t\t att_type = " + sact.Att_type;
                        log += ",\t\t beCrit = " + sact.BeCrit;
                        log += ",\t\t cur_hp = " + sact.Cur_hp;
                        log += ",\t\t heti_idx = " + sact.Heti_idx;

                        StepAction attack = new StepAction();
                        if (sact.buffInfoList != null)
                        {
                            foreach (DataBuffInfo buf in sact.buffInfoList)
                            {
                                BuffInfo attBuf = new BuffInfo();
                                attBuf.buf_id    = buf.Buf_id;
                                attBuf.buf_value = buf.Buf_value;
                                attack.buff.Add(attBuf);
                                log += ",\t\t buf.Buf_id = " + buf.Buf_id;
                                log += ",\t\t buf.Buf_value = " + buf.Buf_value;
                            }
                        }
                        attack.slotIndex = sact.Card_idx;
                        attack.skillID   = sact.Skillid;
                        attack.attackHp  = sact.Att_value;
                        attack.harmType  = sact.Att_type;
                        attack.isStorm   = Convert.ToBoolean(sact.BeCrit);
                        attack.curHp     = sact.Cur_hp;
                        if (sact.HasHeti_idx)
                        {
                            attack.hetiIndex = sact.Heti_idx;
                        }
                        step.attacks.Add(attack);
                        Debug.LogWarning(log);
                    }

                    foreach (DataSingleAction sact in action.be_attacker_actionsList)
                    {
                        string log = "Behit action: ";
                        log += ",\t\t card_idx = " + sact.Card_idx;
                        log += ",\t\t skillid = " + sact.Skillid;
                        log += ",\t\t att_value = " + sact.Att_value;
                        log += ",\t\t att_type = " + sact.Att_type;
                        log += ",\t\t beCrit = " + sact.BeCrit;
                        log += ",\t\t cur_hp = " + sact.Cur_hp;
                        log += ",\t\t heti_idx = " + sact.Heti_idx;

                        StepAction behit = new StepAction();
                        if (sact.buffInfoList != null)
                        {
                            foreach (DataBuffInfo buf in sact.buffInfoList)
                            {
                                BuffInfo behitBuf = new BuffInfo();
                                behitBuf.buf_id    = buf.Buf_id;
                                behitBuf.buf_value = buf.Buf_value;
                                behit.buff.Add(behitBuf);
                                log += ",\t\t buf.Buf_id = " + buf.Buf_id;
                                log += ",\t\t buf.Buf_value = " + buf.Buf_value;
                            }
                        }
                        behit.slotIndex = sact.Card_idx;
                        behit.skillID   = sact.Skillid;
                        behit.attackHp  = sact.Att_value;
                        behit.harmType  = sact.Att_type;
                        behit.isStorm   = Convert.ToBoolean(sact.BeCrit);
                        behit.curHp     = sact.Cur_hp;
                        step.behits.Add(behit);
                        Debug.LogWarning(log);
                    }
                    turn.battleSteps.Add(step);
                }
                battleRound.battleTurns.Add(turn);
            }
        }
 public void SetBattleTurn(BattleTurn value)
 {
     currentTurn = value;
 }
Exemplo n.º 9
0
 /*
  * /////// Turn loop ////////
  * Team1 starts turn
  * Team1 can select units to hire
  * Team1 finishes selection
  * Team1 can move units from tile to tile
  * Team1 can end movement
  * Team1 can hire last units
  * Team1 ends turn
  * play moves to team 2
  * Team 2 can make all moves team 1 has made
  * once team 2 ends turn, play returns to team1
  * /
  * Team1 attacks
  * Team2 defends
  * damage is calculated
  * turn ends
  * attacker and defender roles switch
  * */
 private void Start()
 {
     battleTurn = new BattleTurn();
 }
Exemplo n.º 10
0
 public void FinishBattle()
 {
     PlayerTurnCursor.gameObject.SetActive(false);
     MonsterTurnCursor.gameObject.SetActive(false);
     CurrentTurn = BattleTurn.Finished;
 }
Exemplo n.º 11
0
 private void Start()
 {
     CurrentTurn = BattleTurn.Player;
     Monster.SetNextMove();
 }
Exemplo n.º 12
0
 public BattleTurn(BattleTurn bt)
 {
     bt.TakeTurn();
 }
Exemplo n.º 13
0
    // Update is called once per frame
    void Update()
    {
        endCombatCheck = true;
        foreach (GameObject enemy in Enemies)
        {
            if (enemy.GetComponent <EnemyStateMachine>().currentState != EnemyStateMachine.TurnState.DEAD)
            {
                endCombatCheck = false;
            }
        }
        if (endCombatCheck)
        {
            endCombatWin();
        }
        endCombatCheck = true;
        foreach (GameObject hero in Heros)
        {
            if (hero.GetComponent <HeroStateMachine>().currentState != HeroStateMachine.TurnState.DEAD)
            {
                endCombatCheck = false;
            }
        }
        if (endCombatCheck)
        {
            endCombatLoss();
        }
        switch (battleState)
        {
        case (PerformAction.WAIT):
            if (PerformList.Count > 0)
            {
                battleState = PerformAction.TAKEACTION;
            }
            break;

        case (PerformAction.TAKEACTION):
            GameObject performer = GameObject.Find(PerformList[0].AttackerName);
            if (PerformList[0].Type == "Enemy")
            {
                EnemyStateMachine ESM;
                try
                {
                    ESM = performer.GetComponent <EnemyStateMachine>();
                } catch
                {
                    PerformList.RemoveAt(0);
                    battleState = PerformAction.WAIT;
                    break;
                }
                ESM.heroToAttack = PerformList[0].Defender;
                ESM.currentState = EnemyStateMachine.TurnState.ACTION;
                battleState      = PerformAction.PERFORMACTION;
            }
            else if (PerformList[0].Type == "Hero")
            {
                HeroStateMachine HSM;
                try
                {
                    HSM = performer.GetComponent <HeroStateMachine>();
                }
                catch
                {
                    PerformList.RemoveAt(0);
                    battleState = PerformAction.WAIT;
                    break;
                }
                HSM.enemyToAttack = PerformList[0].Defender;
                HSM.currentState  = HeroStateMachine.TurnState.ACTION;
                battleState       = PerformAction.PERFORMACTION;
            }
            break;

        case (PerformAction.PERFORMACTION):
            GameObject person = GameObject.Find(PerformList[0].AttackerName);
            if (PerformList[0].Type == "Enemy")
            {
                EnemyStateMachine ESM = person.GetComponent <EnemyStateMachine>();
                if (ESM.currentState == EnemyStateMachine.TurnState.DEAD)
                {
                    PerformList.RemoveAt(0);
                    battleState = PerformAction.WAIT;
                }
            }
            else if (PerformList[0].Type == "Hero")
            {
                HeroStateMachine HSM = person.GetComponent <HeroStateMachine>();
                if (HSM.currentState == HeroStateMachine.TurnState.DEAD)
                {
                    PerformList.RemoveAt(0);
                    battleState = PerformAction.WAIT;
                }
            }
            break;
        }
        switch (HeroInput)
        {
        case (HeroGUI.ACTIVATE):
            pause = false;
            if (HerosToManage.Count > 0)
            {
                pause = true;
                HerosToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                HeroTurn = new BattleTurn();

                attackPanel.SetActive(true);
                HeroInput = HeroGUI.WAITING;
            }
            break;

        case (HeroGUI.WAITING):
            break;

        case (HeroGUI.DONE):
            HeroInputDone();
            break;
        }
    }
Exemplo n.º 14
0
 public void GatherActions(BattleTurn input)
 {
     PerformList.Add(input);
 }