예제 #1
0
 public void Disable(int order)
 {
     state = GridState.Disable;
     Order = order;
     gridRender.enabled = false;
     gridSprite.enabled = false;
     unit = null;
 }
예제 #2
0
        public void Disarmament()
        {
            List <GameObject> list = stacks.Values.ToList();

            stacks.Clear();
            for (int i = list.Count - 1; i >= 0; i--)
            {
                GameObject go = list[i];
                Destroy(go);
            }
            unit = null;
        }
예제 #3
0
        public bool ConverseLegionBattleModel()
        {
            legions.Clear();
            List <int> keys = playerData.legions.Keys.ToList();

            for (int index = 0; index < keys.Count; index++)
            {
                Dictionary <int, Unit.Data>        data     = playerData.legions[keys[index]].squadron;;
                Dictionary <int, Unit.BattleModel> squadron = new Dictionary <int, Unit.BattleModel> ();
                for (int order = 0; order < 13; order++)
                {
                    if (data.ContainsKey(order))
                    {
                        Unit.BattleModel unit = new Unit.BattleModel(order, unitModels[data[order].Type], data[order]);
                        squadron.Add(order, unit);
                    }
                }
                legions.Add(keys[index], new Legion.BattleModel(squadron));
            }
            return(true);
        }
예제 #4
0
        public bool Deploy(Unit.BattleModel unit)
        {
            if (state != GridState.Deploy)
            {
                gridRender.enabled = true;
                exitColor          = gray97;
                gridSprite.color   = exitColor;
            }
            this.unit  = unit;
            unit.order = Order;
            int[] array  = new int[unit.model.UnitCount(unit.data.HP)]; // 目前數量
            int[] array2 = new int[unit.model.Formation.Length];        // 最大數量
            for (int i = 0; i < array2.Length; i++)
            {
                array2[i] = 1; // 取得權重,各位置權重相同
            }
            for (int j = 0; j < array.Length; j++)
            {
                int lotteryIndex = unit.model.Field == Unit.Field.Dubi ? GetLotteryIndex(array2) : j; // 只有Dubi要抽位置

                if (state == GridState.Foe)
                {
                    stacks.Add(lotteryIndex, Instantiate(unit.model.Instance, transform.position + unit.model.Formation[unit.model.Formation.Length - 1 - lotteryIndex] * 1, Quaternion.Euler(0, 180, 0)));
                }
                else
                {
                    stacks.Add(lotteryIndex, Instantiate(unit.model.Instance, transform.position + unit.model.Formation[lotteryIndex] * 1, Quaternion.identity));
                }
                array2[lotteryIndex] = 0; // 抽中後將權重改為0
            }
            if (state != GridState.Deploy)
            {
                UpdateList();
            }
            return(true);
        }