Esempio n. 1
0
    public void SetupSpellFX(FG_Spell spell)
    {
        if (!spellFX_preload.ContainsKey(spell.SpellName))
        {
            if (!fx_container.ContainsKey(spell.FX))
            {
                fx_container.Add(spell.FX, new List <GameObject>()
                {
                    Instantiate(FX_lookUp[spell.FX])
                });
            }

            while (fx_container[spell.FX].Count < spell.RangeX.Count)
            {
                fx_container[spell.FX].Add(Instantiate(FX_lookUp[spell.FX]));
            }

            spellFX_preload.Add(spell.SpellName, new List <GameObject>());
            for (int i = 0; i < spell.RangeX.Count; i++)
            {
                fx_container[spell.FX][i].SetActive(false);
                spellFX_preload[spell.SpellName].Add(fx_container[spell.FX][i]);
            }
        }
    }
Esempio n. 2
0
 void AddSpell(FG_Spell spell = null, string spellName = null)
 {
     /*
      * if (PF_GameData.Spells.ContainsKey(spellName))
      * {
      *  FG_SpellDetail spellData = PF_GameData.Spells[spellName];
      *  mySpell = new FG_Spell()
      *  {
      *      SpellName = spellName,
      *      Target = spellData.Target,
      *      ApplyStatus = spellData.ApplyStatus,
      *      Cooldown = spellData.Cooldown,
      *      Description = spellData.Description,
      *      Dmg = spellData.BaseDmg,
      *      Icon = spellData.Icon,
      *      FX = spellData.FX,
      *      RangeX = spellData.RangeX,
      *      RangeY = spellData.RangeY,
      *      LevelReq = spellData.LevelReq,
      *  };
      *
      *  //Debug.LogError(string.Format("character Level : {0} | Spell Level : {1} ", actionBar.controlledPlayer.savedCharacter.characterData.CharacterLevel, mySpell.LevelReq));
      *
      * }
      *
      * btn.interactable = false;
      */
     mySpell          = spell;
     btn.interactable = false;
 }
Esempio n. 3
0
 public void InitState()
 {
     remainingMovement = savedCharacter.PlayerVitals.Speed;
     currentPath       = null;
     selectedSpell     = null;
     attackTarget      = null;
 }
Esempio n. 4
0
    void AddSpell(string spellName)
    {
        if (PF_GameData.Spells.ContainsKey(spellName))
        {
            FG_SpellDetail spellData = PF_GameData.Spells[spellName];
            FG_Spell       sp        = new FG_Spell()
            {
                SpellName   = spellName,
                Target      = spellData.Target,
                ApplyStatus = spellData.ApplyStatus,
                Cooldown    = spellData.Cooldown,
                Description = spellData.Description,
                Dmg         = spellData.BaseDmg,
                Icon        = spellData.Icon,
                FX          = spellData.FX,
                RangeX      = spellData.RangeX,
                RangeY      = spellData.RangeY,
                LevelReq    = spellData.LevelReq
            };

            //if (savedCharacter.characterData.CharacterLevel >= sp.LevelReq)
            //{
            this.mySpells.Add(spellName, sp);
            this.unitController.spellController.SetupSpellFX(sp);
            //}
            //else
            //Debug.Log(string.Format("character level : {0} is too low to use spell : {1} and required level : {2}.", savedCharacter.characterData.CharacterLevel, sp.SpellName, sp.LevelReq));
        }
        else
        {
            Debug.LogError(" Do not contain this spell data : __ " + spellName);
        }
    }
Esempio n. 5
0
 public void ShowFX(Unit attacker, string FX_name = null, FG_Spell spell = null)
 {
     for (int i = 0; i < spell.RangeX.Count; i++)
     {
         spellFX_preload[spell.SpellName][i].transform.position = new Vector2(attacker.tileX + spell.RangeX[i], attacker.tileY + spell.RangeY[i]);
         spellFX_preload[spell.SpellName][i].SetActive(true);
     }
     if (audio_lookup.ContainsKey(spell.SpellName))
     {
         GameController.Instance.soundManager.PlaySound(attacker.transform.position, audio_lookup[spell.SpellName]);
     }
 }
Esempio n. 6
0
    void IsSpellApplyStatus(Unit unit, FG_Spell spell)
    {
        if (spell.ApplyStatus == null)
        {
            return;
        }

        foreach (var go in unitControlller.UintInSpellRange())
        {
            float          rng          = Random.Range(0f, 1f);
            bool           success      = (spell.ApplyStatus.ChanceToApply >= rng) ? true : false;
            FG_SpellStatus activeStatus = go.savedCharacter.PlayerVitals.ActiveStati.Find(x => x.StatusName.Contains(spell.ApplyStatus.StatusName));
            if (success && activeStatus == null)
            {
                FG_SpellStatus status = new FG_SpellStatus()
                {
                    ChanceToApply     = spell.ApplyStatus.ChanceToApply,
                    FX                = spell.ApplyStatus.FX,
                    Icon              = spell.ApplyStatus.Icon,
                    ModifyAmount      = spell.ApplyStatus.ModifyAmount,
                    StatModifierCode  = spell.ApplyStatus.StatModifierCode,
                    StatusDescription = spell.ApplyStatus.StatusDescription,
                    StatusName        = spell.ApplyStatus.StatusName,
                    Target            = spell.ApplyStatus.Target,
                    Turns             = spell.ApplyStatus.Turns
                };

                go.savedCharacter.PlayerVitals.ActiveStati.Add(status);
                unitControlller.spellController.TriggerImmediately(go, go.savedCharacter.PlayerVitals.ActiveStati.Count - 1);

                if (status.Target.Contains("Player"))
                {
                    go.EnableBuff(true);
                }
                else if (status.Target.Contains("Enemy"))
                {
                    go.EnableBuff(false);
                }

                Debug.Log("rng : " + rng + " | ChanceToApply : " + spell.ApplyStatus.ChanceToApply);
            }
            else if (success && activeStatus != null)
            {
                Debug.Log("unit is under effecting");
            }
            else
            {
                Debug.Log("Spell status did not trigged !");
            }
        }
    }
Esempio n. 7
0
    public void Init(string spellName, FG_Spell spell, GamePlayActionBar bar)
    {
        actionBar = bar;
        AddSpell(spell);
        text.text = spellName;

        if (!cdTurns.ContainsKey(actionBar.controlledPlayer.name))
        {
            cdTurns.Add(actionBar.controlledPlayer.name, 0);
        }

        btn.onClick.RemoveAllListeners();
        btn.onClick.AddListener(() => { actionBar.OnSpellSlotClicked(this); });
    }
Esempio n. 8
0
    public int DmgCalculator(FG_SavedCharacter Attacker, FG_SavedCharacter target, FG_Spell spell)
    {
        int dmg        = 0;
        int spellPower = spell.Dmg;
        int AtkPoint   = Attacker.PlayerVitals.Attack;
        int DefPoint   = target.PlayerVitals.Defense;

        if (spellPower <= 0)
        {
            return(0);
        }
        else
        {
            dmg = (int)(0.5f * (float)spellPower * (float)AtkPoint / (float)DefPoint) + 1;
        }

        Debug.Log(spellPower + "|" + AtkPoint + "|" + DefPoint + "|" + dmg);
        return(dmg);
    }
Esempio n. 9
0
    public void ShowTargetBySpellRange(FG_Spell spell)
    {
        //需要同步allcharacterunit的master and clinet 的排序

        if (spell == null)
        {
            return;
        }

        if (PhotonNetwork.isMasterClient || IsMultiPlayer)
        {
            map.ShowSpellRange();
            foreach (var go in unitControlller.allCharacterUnit)
            {
                if (go.selectedMask == null)
                {
                    continue;
                }

                if (spell.RangeX.Contains(go.tileX - unitControlller.allCharacterUnit[unitControlller.currentId].tileX) && spell.RangeY.Contains(go.tileY - unitControlller.allCharacterUnit[unitControlller.currentId].tileY))
                {
                    go.selectedMask.SetActive(true);
                }
            }
        }
        else //(!PhotonNetwork.isMasterClient)
        {
            map.ShowSpellRange();
            foreach (var go in unitControlller.allCharacterUnit)
            {
                if (go.selectedMask == null)
                {
                    continue;
                }

                if (spell.RangeX.Contains(go.tileX - map.selectedUnit.tileX) && spell.RangeY.Contains(go.tileY - map.selectedUnit.tileY))
                {
                    go.selectedMask.SetActive(true);
                }
            }
        }
    }
Esempio n. 10
0
    public void ShowSpellRange()
    {
        Unit     unit  = selectedUnit;
        FG_Spell spell = selectedUnit.selectedSpell;

        for (int i = 0; i < spell.RangeX.Count; i++)
        {
            for (int j = 0; j < spell.RangeY.Count; j++)
            {
                ClickableTile ct;
                ct = FindTile(unit.tileX + spell.RangeX[i], unit.tileY + spell.RangeY[j]);

                if (ct == null || ct.atkMask == null)
                {
                    continue;
                }
                ct.atkMask.SetActive(true);
            }
        }
    }
Esempio n. 11
0
    public void RandomSpell(string beSelected = null)
    {
        if (beSelected != null)
        {
            if (this.mySpells[beSelected] != null)
            {
                this.selectedSpell = this.mySpells[beSelected];
            }
            else
            {
                Debug.LogError(" my spells do not contain the spell __ " + beSelected);
            }
            return;
        }

        int rng = UnityEngine.Random.Range(0, this.mySpells.Count);

        this.selectedSpell = this.mySpells.Values.ToList()[rng];
        //Debug.Log("Is going to use " + sp.Icon + " and it caused " + sp.BaseDmg + " damage to enemy");
    }
Esempio n. 12
0
    public void ShowFX(GameObject objectToEffect, FG_Spell spell = null)
    {
        if (spell != null && spellFX_preload.ContainsKey(spell.SpellName))
        {
            GameObject go = spellFX_preload[spell.SpellName][0];
            go.transform.position = objectToEffect.transform.position;
            go.SetActive(true);

            if (audio_lookup.ContainsKey(spell.SpellName))
            {
                GameController.Instance.soundManager.PlaySound(objectToEffect.transform.position, audio_lookup[spell.SpellName]);
            }
        }
        else
        {
            GameObject go = fx_container["CFX2_RockHit"][0];//Instantiate(FX_lookUp["CFX_Virus"]);
            go.transform.position = objectToEffect.transform.position;
            go.SetActive(true);

            //if (audio_lookup.ContainsKey(spell.SpellName))
            GameController.Instance.soundManager.PlaySound(objectToEffect.transform.position, audioClip_Resources[0]);
        }
    }