Пример #1
0
    public IEnumerator SpellAnimation(SpellType spellName)
    {
        canPlay = false;
        Sc_EventManager.instance.onUpdateStats.Invoke();
        Sequence sequence = DOTween.Sequence();

        switch (spellName)
        {
        case SpellType.Ice:
            screen.color = Color.cyan;
            break;

        case SpellType.Fire:
            screen.color = Color.red;
            break;

        case SpellType.Shield:
            screen.color = Color.blue;
            break;
        }

        screen.color = new Color(screen.color.r, screen.color.g, screen.color.b, 0);
        txt.text     = spellName.ToString();
        sequence.Append(screen.DOFade(0.4f, 0.15f));
        sequence.Play().SetAutoKill(false);
        yield return(new WaitForSeconds(sequence.Duration() * 2));

        sequence.PlayBackwards();
        yield return(new WaitForSeconds(sequence.Duration()));

        canPlay = true;
        Sc_EventManager.instance.onUpdateStats.Invoke();
    }
Пример #2
0
        public override string ToString()
        {
            string toString = Name;

            foreach (string s in AllowedClasses)
            {
                toString += ", " + s;
            }

            foreach (string s in AttributeRequirements.Keys)
            {
                toString += ", " + s + "+" + AttributeRequirements[s].ToString();
            }

            foreach (String s in SpellPrerequisites)
            {
                toString += ", " + s;
            }

            toString += ", " + LevelRequirement;
            toString += ", " + SpellType.ToString();
            toString += ", " + ActivationCost.ToString();

            foreach (string s in Effects)
            {
                toString += ", " + s;
            }

            return(toString);
        }
Пример #3
0
        public override string ToString()
        {
            string toString = Name;

            foreach (string s in AllowedClasses)
            {
                toString += ", " + s;
            }

            foreach (string s in AttributeRequirements.Keys)
            {
                toString += ", " + s + "+" + AttributeRequirements[s].ToString();
            }

            if (SpellPrerequisites != null)
            {
                foreach (string s in SpellPrerequisites)
                {
                    toString += ", " + s;
                }
            }

            toString += ", " + LevelRequirement.ToString();
            toString += ", " + SpellType.ToString();
            toString += ", " + ActivationCost.ToString();
            toString += ", " + CoolDown.ToString();

            foreach (BaseEffectData e in Effects)
            {
                toString += ", " + e.ToString();
            }

            return(toString);
        }
Пример #4
0
    public GameObject SpawnSpellFromPool(SpellType spellType, Vector3 position, Quaternion rotation)
    {
        if (!m_spellPoolDictionary.ContainsKey(spellType))
        {
            Debug.LogError("Pool of " + spellType + " dosen't exist.");
            return(null);
        }

        if (m_spellPoolDictionary[spellType].Count == 0)
        {
            Debug.LogError(spellType.ToString() + " pool is empty!");
            return(null);
        }

        GameObject objectToSpawn = m_spellPoolDictionary[spellType].Dequeue();

        objectToSpawn.transform.position = position;
        objectToSpawn.transform.rotation = rotation;
        objectToSpawn.SetActive(true);

        PoolTracker poolTracker = AddPoolTrackerComponent(objectToSpawn, PoolType.SpellType);

        poolTracker.SpellType = spellType;
        m_trackedObject.Enqueue(poolTracker);

        return(objectToSpawn);
    }
Пример #5
0
    public void SetType()
    {
        type = Spell.instance.active[Random.Range(0, Spell.instance.active.Count)];
        // type = (SpellType)Random.Range(0, System.Enum.GetValues(typeof(SpellType)).Length);

        // set tag
        gameObject.tag = type.ToString() + "Tile";
    }
Пример #6
0
        /// <summary>
        /// Gets disabled spell object or spawn one if could not find any
        /// </summary>
        /// <param name="spellType"></param>
        /// <returns></returns>
        private ISpell GetNonactiveSpellOfType(SpellType spellType)
        {
            ISpell spell = _nonactiveSpells.Find(s => s.SpellType == spellType);

            if (spell == null)
            {
                GameObject prefab = Resources.Load <GameObject>("Spells/" + spellType.ToString());
                spell = Instantiate(prefab, transform).GetComponent <ISpell>();
                _nonactiveSpells.Add(spell);
            }

            return(spell);
        }
        /// <summary>
        /// Gets disabled spell object or spawn one if could not find any
        /// </summary>
        /// <param name="spellType"></param>
        /// <returns></returns>
        private ISpell GetNonactiveSpellOfType(SpellType spellType)
        {
            ISpell spell = _nonactiveSpells.Find(s => s.SpellType == spellType);

            if (spell == null)
            {
                GameObject prefab = Resources.Load <GameObject>("Spells/" + spellType.ToString());
                spell = GameObject.Instantiate(prefab).GetComponent <ISpell>();
                var asFireball = spell as Fireball;
                if (asFireball)
                {
                    asFireball.Init(_stateManager, _isHost);
                }

                _nonactiveSpells.Add(spell);
            }

            return(spell);
        }
Пример #8
0
    private static BulletDisplay InitBullet(Transform attackTrans, ShipDisplay targetShip, Transform targetTrans, SpellType spellType, string bulletPath, Effect hurtEffect)
    {
        GameObject bullet = AssetLoader.PlayEffect(bulletPath);

        if (bullet == null)
        {
            Debug.Log("can not find bullet:" + bulletPath);
            bullet = new GameObject();
            //return null;
        }
        bullet.name = spellType.ToString();
        bullet.transform.position = attackTrans.position;
        bullet.transform.rotation = attackTrans.rotation;
        BulletDisplay display = bullet.GetComponent <BulletDisplay>();

        if (display == null)
        {
            display = bullet.AddComponent <BulletDisplay>();
        }
        display.SetCache(attackTrans, targetShip, targetTrans, spellType, bulletPath, hurtEffect);
        return(display);
    }
Пример #9
0
 public InvalidSpellException(SpellType spellType)
     : base("Invalid spell type: " + spellType.ToString())
 {
 }
Пример #10
0
    /// <summary>
    /// Показ выбранного бонуса/заклинания
    /// </summary>
    /// <param name="selected">Индекс бонуса/заклинания</param>
    private void ShowBonus(int selected)
    {
        GUILayout.BeginHorizontal();
        selectedBonus = EditorGUILayout.Popup(selectedBonus, bonusNames.ToArray());

        editButt = GUILayout.Button("Edit");
        addButt  = GUILayout.Button("Add new");
        GUILayout.EndHorizontal();

        GUILayout.Label("Полное описание бонуса:", EditorStyles.boldLabel);
        GUILayout.Space(10);

        GUILayout.BeginHorizontal();
        GUILayout.Label("Название(уникальное имя):");
        GUILayout.Label(bonusList[selected].unikName);
        _unikName = bonusList[selected].unikName;
        GUILayout.EndHorizontal();

        GUILayout.Space(5);
        GUILayout.BeginHorizontal();
        GUILayout.Label("Тип(для вызова):");
        GUILayout.Label(_type.ToString());
        _type = bonusList[selected].type;
        GUILayout.EndHorizontal();

        GUILayout.Space(5);
        GUILayout.BeginHorizontal();
        GUILayout.Label("Полное описание бонуса/заклинания(для игрока):");
        GUILayout.Label(bonusList[selected].fullName);
        _fullName = bonusList[selected].fullName;
        GUILayout.EndHorizontal();

        GUILayout.Space(5);
        GUILayout.BeginHorizontal();
        GUILayout.Label("Цель:");
        GUILayout.Label(bonusList[selected].target.ToString());
        _target = bonusList[selected].target;
        GUILayout.EndHorizontal();

        //Если это хилка, атаку не отображаем
        if (bonusList[selected].type != SpellType.heal)
        {
            GUILayout.Space(5);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Значение attack:");
            GUILayout.Label(bonusList[selected].att.ToString());
            _att = bonusList[selected].att;
            GUILayout.EndHorizontal();
        }

        if (bonusList[selected].type != SpellType.damage)
        {
            GUILayout.Space(5);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Значение HP:      ");
            GUILayout.Label(bonusList[selected].hp.ToString());
            _hp = bonusList[selected].hp;
            GUILayout.EndHorizontal();
        }

        GUILayout.Space(10);

        //Помогайка
        EditorGUILayout.HelpBox("Главные сокращения:" +
                                "\nCreature-cr, destroy - dist," +
                                "\nЕсли необходимо сделать, например, +att/-hp, будет написано bust/debust", MessageType.Info);

        #region Сохранение в файл
        if (GUILayout.Button(new GUIContent("Save", "Сохраняет все новое/редактированное в файл")))
        {
            List <string> saveNames = new List <string>();    //Списокдля сохранения

            foreach (BonusData bd in bonusList)
            {
                saveNames.Add(JsonUtility.ToJson(bd));
            }

            File.WriteAllLines(path, saveNames.ToArray());
            Debug.Log("Bonuses saved");
        }
        #endregion
    }
Пример #11
0
 public static List <GameObject> GetAllTilesOfType(SpellType type)
 {
     GameObject[] chain = GameObject.FindGameObjectsWithTag(type.ToString() + "Tile");
     return(chain.ToList());
 }
        public static void Main()
        {
            Cell[][] lair = new Cell[15][];
            for (int i = 0; i < lair.Length; i++)
            {
                lair[i] = new Cell[15];

                for (int j = 0; j < lair[i].Length; j++)
                {
                    lair[i][j] = new Cell()
                    {
                        Row    = i,
                        Column = j
                    };
                }
            }

            int playerRow    = 7;
            int playerColumn = 7;

            double hitPointsHeigan = 3000000;
            int    hitPointsPLayer = 18500;

            double    playerDamagePerTurn = double.Parse(Console.ReadLine());
            bool      playerAffectedByCloudFromPreviousRound = false;
            bool      playerIsAlive = true;
            bool      HeiganIsAlive = true;
            SpellType lastSpellDamagingThePlayer = SpellType.None;

            while (playerIsAlive && HeiganIsAlive)
            {
                string[]  roundInput  = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                SpellType spellType   = (SpellType)Enum.Parse(typeof(SpellType), roundInput[0]);
                int       spellRow    = int.Parse(roundInput[1]);
                int       spellColumn = int.Parse(roundInput[2]);

                // It is stated that both Heigan and the player may die at the same turn, so the player must deal damage first (even before Plague Cloud effects)
                hitPointsHeigan -= playerDamagePerTurn;

                if (hitPointsHeigan <= 0)
                {
                    HeiganIsAlive = false;
                }

                // Deal cloud damage if any
                if (playerAffectedByCloudFromPreviousRound)
                {
                    hitPointsPLayer           -= 3500;
                    lastSpellDamagingThePlayer = SpellType.Cloud;
                    // Reset Plague Cloud effect
                    playerAffectedByCloudFromPreviousRound = false;
                }

                if (hitPointsPLayer <= 0)
                {
                    playerIsAlive = false;
                    break;
                }

                if (HeiganIsAlive)
                {
                    AffectCells(lair, spellType, spellRow, spellColumn);
                }

                // Try move player if he is affected by a spell
                (playerRow, playerColumn) = TryMovePlayer(playerRow, playerColumn, lair);

                // Deal damage to player if he has not escaped the spell
                if (lair[playerRow][playerColumn].AffectedBy == SpellType.Cloud)
                {
                    playerAffectedByCloudFromPreviousRound = true;
                    hitPointsPLayer           -= 3500;
                    lastSpellDamagingThePlayer = SpellType.Cloud;
                }
                else if (lair[playerRow][playerColumn].AffectedBy == SpellType.Eruption)
                {
                    hitPointsPLayer           -= 6000;
                    lastSpellDamagingThePlayer = SpellType.Eruption;
                }

                if (hitPointsPLayer <= 0)
                {
                    playerIsAlive = false;
                    break;
                }

                ClearSpellEffectsFromCells(lair);
            }

            Console.WriteLine(HeiganIsAlive ? ("Heigan: " + String.Format("{0:0.00}", hitPointsHeigan)) : "Heigan: Defeated!");
            Console.WriteLine(playerIsAlive ? ("Player: " + hitPointsPLayer) : "Player: Killed by " + (lastSpellDamagingThePlayer == SpellType.Cloud ? "Plague Cloud" : lastSpellDamagingThePlayer.ToString()));
            Console.WriteLine($"Final position: {playerRow}, {playerColumn} ");
        }
Пример #13
0
 public void SetSprite()
 {
     rect.GetComponent <Image>().sprite = Resources.Load <Sprite>("Textures/t_" + type.ToString().ToLower());
 }