Exemple #1
0
 //离开战场
 public void LeaveBattleField()
 {
     if (battleField != null)
     {
         for (int i = 0; i < battleUnits.Count; i++)
         {
             battleUnits[i].LeaveBattleField();
         }
         battleField = null;
     }
 }
        //战场连接
        public void OnConnect(BattleField field)
        {
            battleField = field;
            //加载战场
            RefreshBattleMapGrids();
            //加载战斗单位
            RefreshBattleUnits();

            EventManager.Instance.Register(EGameConstL.EVENT_BATTLE_UNIT_USE_ITEM,
                                           this.gameObject.RequestorSTR(),
                                           OnBattleUnitUseItem);
        }
Exemple #3
0
        public void RunManualTest()
        {
            //创建战斗(数据)
            singleBattle = BattleFieldCreator.Instance.Create(
                mapSize.x, mapSize.y,
                obstacleCount, obstacleGap, buffCount, itemCount,
                teamA, teamB);

            //重置相机和尺寸
            ResetBattleCamera();

            singleBattle.ConnectRenderer(BattleFieldRenderer.Instance);

            singleBattle.Run();
        }
Exemple #4
0
        private void RunManualTest()
        {
            //创建战斗(数据)
            singleBattle = BattleCreator.Instance.CreateBattle(
                mapSize.x, mapSize.y,
                obstacleCount, obstacleGap,
                battleUnitCount);

            //重置相机和尺寸
            ResetBattleCamera();

            singleBattle.ConnectRenderer(BattleFieldRenderer.Instance);

            singleBattle.Run();
        }
Exemple #5
0
        //进入战场
        public void EnterBattleField(BattleField battleField, GridUnit bornGrid)
        {
            if (battleField != null && bornGrid != null)
            {
                this.battleField = battleField;

                //设置敌方队伍
                enemyTeam = battleField.GetBattleTeam(this, false);

                //重置属性
                battleUnitAttribute.RandomAttributes();
                battleUnitAttribute.Reset();

                //创建背包
                if (package == null)
                {
                    package = BattleUnitPackage.CreateInstance(this, 2);
                }

                package.Clear();

                //进入战场
                BattleUnitEnterBattleFieldAction enterBattleFieldAction = BattleUnitActionEvent.CreateEvent <BattleUnitEnterBattleFieldAction>(BattleUnitActionType.EnterBattleField, this);
                enterBattleFieldAction.battleField             = battleField;
                enterBattleFieldAction.bornGrid                = bornGrid;
                enterBattleFieldAction.attribute               = new BattleUnitSyncAttribute();
                enterBattleFieldAction.attribute.hpChanged     = 0;
                enterBattleFieldAction.attribute.currentHP     = battleUnitAttribute.hp;
                enterBattleFieldAction.attribute.energyChanged = 0;
                enterBattleFieldAction.attribute.currentEnergy = 0;
                battleField.AppendBattleAction(enterBattleFieldAction);

                //进入格子
                EnterGrid(bornGrid);

                //初始化战斗行为系统
                if (battleBehaviourSystem != null)
                {
                    battleBehaviourSystem.Init(this, battleField);
                }

                //重置bbsys
                if (battleBehaviourSystem != null)
                {
                    battleBehaviourSystem.ResetSystem();
                }
            }
        }
Exemple #6
0
        //进入战场
        public void EnterBattleField(BattleField battleField, GridUnit bornGrid, List <BattleAction> heroActions)
        {
            if (battleField != null && bornGrid != null)
            {
                this.battleField = battleField;

                EnterGrid(bornGrid);

                if (heroActions != null)
                {
                    BattleHeroEnterBattleFieldAction action = new BattleHeroEnterBattleFieldAction(this);
                    action.gridUnit            = bornGrid;
                    action.attribute           = new BattleHeroSyncAttribute();
                    action.attribute.hpChanged = 0;
                    action.attribute.currentHP = hp;
                    heroActions.Add(action);
                }
            }
        }
Exemple #7
0
        //进入战场
        public BattleHeroEnterBattleFieldAction EnterBattleField(BattleField battleField, GridUnit bornGrid, bool generateAction)
        {
            if (battleField != null && bornGrid != null)
            {
                this.battleField = battleField;

                EnterGrid(bornGrid);

                //需要产生一条
                if (generateAction)
                {
                    BattleHeroEnterBattleFieldAction action = new BattleHeroEnterBattleFieldAction(this);
                    action.gridUnit            = bornGrid;
                    action.attribute           = new BattleHeroSyncAttribute();
                    action.attribute.hpChanged = 0;
                    action.attribute.currentHP = hp;
                    return(action);
                }
            }
            return(null);
        }
Exemple #8
0
        private void OnGUI()
        {
            if (!battleFiledRendererIsReady)
            {
                return;
            }

            if (singleBattle == null)
            {
                if (GUI.Button(new Rect(0, 0, 150, 100), "Create battle"))
                {
                    if (testCount > 0)
                    {
                        StartCoroutine(RunTest());
                        return;
                    }
                    //创建战斗(数据)
                    singleBattle = BattleCreator.Instance.CreateBattle(
                        mapSize.x, mapSize.y,
                        obstacleCount, obstacleGap,
                        battleUnitCount);

                    //重置相机和尺寸
                    ResetBattleCamera();

                    //战斗计算(保留战斗过程)
                    singleBattle.Run(true);

                    //连接到显示器
                    singleBattle.ConnectRenderer(BattleFieldRenderer.Instance);

                    //显示战斗过程
                    StartCoroutine(BattleFieldRenderer.Instance.PlayBattleActions());
                }
            }
        }
Exemple #9
0
 private void Awake()
 {
     instance = this;
 }