Exemplo n.º 1
0
        /// <summary>
        /// 範囲内の<see cref="IReceiveBuff"/>にバフを与える
        /// </summary>
        private void ApplyBuff(float addValue)
        {
            var receiveBuffs = new List <IReceiveBuff>();

            Vector2IntUtility.GetRange(this.Origin, this.levelParameter.ImpactRange, (pos) =>
            {
                var cellEventMap = GameSystem.Instance.CellManager.Mapper.CellEvent.Map;
                if (!cellEventMap.ContainsKey(pos))
                {
                    return(false);
                }

                var receiveBuff = cellEventMap[pos] as IReceiveBuff;
                if (receiveBuff == null)
                {
                    return(false);
                }

                if (receiveBuffs.Contains(receiveBuff))
                {
                    return(false);
                }

                receiveBuffs.Add(receiveBuff);

                return(true);
            });

            foreach (var b in receiveBuffs)
            {
                b.AddBuff(addValue);
            }
        }
Exemplo n.º 2
0
    public void InvokeAddCellEventFacility()
    {
        const int facilityId  = 101000;
        var       cellManager = GameSystem.Instance.CellManager;

        Vector2IntUtility.GetRange(Vector2Int.zero, this.addCellRange, (id) =>
        {
            var cell = cellManager.Mapper.Cell.Map[id];
            if (cellManager.Mapper.CellEvent.Map.ContainsKey(id))
            {
                cellManager.EventGenerator.Remove(cell);
            }

            cellManager.EventGenerator.Generate(cell, facilityId, false);

            return(true);
        });
    }
Exemplo n.º 3
0
    public void InvokeAddCellRange()
    {
        const int grasslandId = 100100;
        var       cellManager = GameSystem.Instance.CellManager;

        Vector2IntUtility.GetRange(Vector2Int.zero, this.addCellRange, (id) =>
        {
            if (cellManager.Mapper.Cell.Map.ContainsKey(id))
            {
                cellManager.CellGenerator.Replace(grasslandId, id);
            }
            else
            {
                cellManager.CellGenerator.Generate(grasslandId, id, 99999);
            }

            return(true);
        });
    }
Exemplo n.º 4
0
        public Constants.CellEventGenerateEvalute CanGenerate(Cell origin, int cellEventRecordId, CellMapper cellMapper)
        {
            Assert.IsNotNull(this.condition);

            var cellPositions = Vector2IntUtility.GetRange(origin.Position, Vector2Int.one * this.size, p => cellMapper.Cell.Map.ContainsKey(p));

            // 配置したいところにセルがない場合は生成できない
            if (cellPositions.Count != this.size * this.size)
            {
                return(Constants.CellEventGenerateEvalute.NotCell);
            }

            // 配置したいセルにイベントがあった場合は生成できない
            var cells = cellMapper.GetCells(cellPositions);

            if (Array.FindIndex(cells, c => cellMapper.HasEvent(c)) != -1)
            {
                return(Constants.CellEventGenerateEvalute.AlreadyExistsCellEvent);
            }

            // コストが満たしていない場合は生成できない
            var gameSystem = GameSystem.Instance;
            var masterData = gameSystem.MasterData.LevelUpCost.Records.Get(cellEventRecordId, 0);

            Assert.IsNotNull(masterData, $"CellEventRecordId = {cellEventRecordId}の{typeof(MasterDataLevelUpCost.Record)}がありませんでした");
            if (!masterData.Cost.IsEnough(gameSystem.User, gameSystem.MasterData.Item))
            {
                return(Constants.CellEventGenerateEvalute.NotEnoughCost);
            }

            // セルイベントごとの条件を満たしていない場合は生成できない
            if (!this.condition.Evalute(cells))
            {
                return(Constants.CellEventGenerateEvalute.NotEnoughCondition);
            }

            return(Constants.CellEventGenerateEvalute.Possible);
        }
Exemplo n.º 5
0
 /// <summary>
 /// 指定した範囲でセルが配置されていない座標を返す
 /// </summary>
 public Vector2Int[] GetEmptyPositions(Vector2Int origin, int range)
 {
     return(Vector2IntUtility.GetRange(origin, range, (p) => !this.cell.Map.ContainsKey(p)).ToArray());
 }