Exemplo n.º 1
0
        //-------------------------------------------------------------------------
        // 属性スキル

        /// <summary>
        /// 属性スキルユニットを生成
        /// </summary>
        public ISkill Create(Define.App.Attribute attribute)
        {
            var unit = GetPoolForSkill(attribute).Create();

            unit.Setup();
            return(unit);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 属性スキル用オブジェクトプールの初期設定
        /// </summary>
        /// <typeparam name="T">Componentであり、ISkillを実装している</typeparam>
        /// <param name="attribute">属性</param>
        private void InitPoolForSkill <T>(Define.App.Attribute attribute) where T : Component, ISkill
        {
            // プール生成
            var pool = new ObjectPool <ISkill>();

            // Generator設定
            pool.SetGenerator(() =>
            {
                return(MyGameObject
                       .Create <T>($"{attribute}", CacheTransform)
                       .Init(attribute));
            });

            // 2人分予約
            pool.Reserve(2);

            // 登録
            this.skills.Add((int)attribute, pool);
        }
Exemplo n.º 3
0
        public void FireAttributeSkill(Define.App.Attribute attribute)
        {
            // 属性スキルを取得
            var skill = SkillManager.Instance.Create(attribute);

            // スキル発動者と対称を取得
            var owner  = this;
            var target = VersusManager.Instance.GetTargetPlayerBy(Type);

            // 自分に対するスキルならtargetを自分に設定
            switch (attribute)
            {
            // 水と聖は対象が自分
            case Define.App.Attribute.Wat:
            case Define.App.Attribute.Hol:
                target = owner;
                break;
            }

            // スキル発動
            skill.Fire(owner, target);
        }
Exemplo n.º 4
0
        //-------------------------------------------------------------------------
        // スキル系

        public bool TryFireAttributeSkill(Define.App.Attribute attribute)
        {
            // 現在のMPと使用MPを取得
            var NowMp = this.status.GetMp(attribute);
            var useMp = this.config.GetUseMp(attribute);

            // スキルに必要なMPが不足していたらスキル発動できない
            if (NowMp < useMp)
            {
                return(false);
            }

            // MP消費
            this.status.AddMp(attribute, -useMp);

            // APを増やす
            this.status.AddAp(1f);

            // スキル発動
            FireAttributeSkill(attribute);
            return(true);
        }
Exemplo n.º 5
0
 /// <summary>
 /// MPを加算
 /// </summary>
 public void AddMp(Define.App.Attribute attribute, float mp)
 {
     this.mp[attribute].Now += mp;
 }
Exemplo n.º 6
0
 /// <summary>
 /// MPを取得
 /// </summary>
 public float GetMp(Define.App.Attribute attribute)
 {
     return(this.mp[attribute].Now);
 }
Exemplo n.º 7
0
 /// <summary>
 /// 消滅数を取得
 /// </summary>
 public int GetVanishCount(Define.App.Attribute attribute)
 {
     return(this.vanishCounts[(int)attribute]);
 }
Exemplo n.º 8
0
 /// <summary>
 /// 消滅情報の更新
 /// </summary>
 public void UpdateVanish(Define.App.Attribute attribute, int count)
 {
     // 属性ごとに消えた数を保持
     this.vanishCounts[(int)attribute] += count;
 }
Exemplo n.º 9
0
        //-------------------------------------------------------------------------
        // ISkill Interfaceの実装

        public virtual ISkill Init(Define.App.Attribute attribute)
        {
            Attribute = attribute;
            return(this);
        }
Exemplo n.º 10
0
 /// <summary>
 /// 属性スキルプールを取得
 /// </summary>
 private ObjectPool <ISkill> GetPoolForSkill(Define.App.Attribute attribute)
 {
     return(this.skills[(int)attribute]);
 }
Exemplo n.º 11
0
        /// <summary>
        /// 属性を指定すると近くの選択可能な肉球の座標を取得する
        /// </summary>
        public bool FindNearPawCoord(Define.App.Attribute attribute, ref Vector2Int coord)
        {
            // 距離
            float distance = -1;

            for (int y = 0; y < Define.Versus.PAW_ROW; ++y)
            {
                for (int x = 0; x < Define.Versus.PAW_COL; ++x)
                {
                    var paw = this.paws[IndexBy(x, y)]; // 探索対象の肉球
                    var pos = new Vector2Int(x, y);     // 探索位置

                    // 既に移動済みのものは除外
                    if (paw.HasMoved)
                    {
                        continue;
                    }

                    // 探している属性と違うなら除外
                    if (paw.Attribute != attribute)
                    {
                        continue;
                    }

                    // 選択できないものは除外
                    if (!paw.CanSelect)
                    {
                        continue;
                    }

                    // カーソルとの距離を測る
                    var tmp = (this.cursorCoord - pos).sqrMagnitude;

                    // 初回じゃなく、現状見つかっているものより遠ければ除外
                    if (0 <= distance && distance < tmp)
                    {
                        continue;
                    }

                    // 連結している肉球の数を調べる
                    var count = 0;
                    LookUpPawConnectable(x, y, ref count);
                    ClearEvaluated(x, y);

                    // 既に連鎖可能な数繋がっていたら除外
                    if (Define.Versus.CHAIN_PAW_COUNT <= count)
                    {
                        continue;
                    }

                    // 近いものがあればその座標を記録し、距離を更新
                    coord.Set(x, y);
                    distance = tmp;

                    // 0距離のものが見つかっているのであればそれ以上近くはないので探索終了
                    if (distance == 0)
                    {
                        return(true);
                    }
                }
            }

            return(0 <= distance);
        }