Example #1
0
    public List <int> CanUnlockSkills()
    {
        List <int> list = new List <int>();

        for (int i = 0; i <= Skills.GetMaxID(); i++)
        {
            Skill skill = Skills.GetDefaultFromSkillInfo(Skills.GetSkillInfoFromID(i));
            if (wave < skill.GetMinimumWave())
            {
                continue;
            }
            bool             can      = true;
            HashSet <string> required = skill.GetPrerequisites();
            foreach (string s in required)
            {
                if (!player.combat.skillLibrary.Exists(x => x != null &&
                                                       Skills.Attr(x.GetID()).title == s))
                {
                    can = false;
                    break;
                }
            }
            if (can)
            {
                list.Add(i);
            }
        }
        return(list);
    }
Example #2
0
    public void DropSkill(string text)
    {
        Skill sk = Skills.GetDefaultFromSkillInfo(Skills.GetSkillInfoFromTitle(text));

        netPlayer.CmdSetSkill(Skills.Attr(sk.GetID()).id, id);
        //pc.combat.skills[id] = sk;
        SetSkill(sk);
    }
Example #3
0
    public virtual bool Initialize()
    {
        startTime = Time.time;
        direction = controller.movement.GetDirection();
        x         = controller.movement.playerX; // + Direction.ValueX (direction);
        y         = controller.movement.playerY; // + Direction.ValueY (direction);
        if (!CanRun())
        {
            return(false);
        }
        HashSet <KeyValuePair <int, int> > willCast = new HashSet <KeyValuePair <int, int> >();
        HashSet <KeyValuePair <int, int> > set      = GetCoordinates();

        foreach (KeyValuePair <int, int> pair in set)
        {
            switch (CanCast(pair))
            {
            case CanCastValue.Yes:
                willCast.Add(pair);
                break;

            case CanCastValue.CancelThis:
                break;                        // Do nothing

            case CanCastValue.CancelAll:
                return(false);
            }
        }
        if (ShouldCancel(willCast))
        {
            return(false);
        }
        foreach (KeyValuePair <int, int> pair in willCast)
        {
            RunAttack(pair);
        }
        foreach (KeyValuePair <int, int> pair in willCast)
        {
            KeyValuePair <int, int> targetPos = LocalToGame(pair);
            GameObject target = controller.movement.map.objects[targetPos.Key, targetPos.Value];
            if (target != null)
            {
                OnHit(target, pair);
            }
        }
        if (!PostCast())
        {
            return(false);
        }
        //TODO add animator
        GameObject.FindGameObjectWithTag("CGameController")
        .GetComponent <ClientAnimation>()
        .RpcAnimateSkill(Skills.Attr(GetInfo()).id, x, y, direction, cooldown);
        return(true);
    }
Example #4
0
    void DisplaySkills(NetworkPlayerController netPlayer)
    {
        List <Skill> sa = player.combat.skillLibrary;

        int[] ia = new int[sa.Count];
        for (int i = 0; i < sa.Count; i++)
        {
            ia[i] = Skills.Attr(sa[i].GetID()).id;
        }
        netPlayer.RpcDisplaySkills(ia);
    }
Example #5
0
    /*void PresentSkills(Skill[] skills){
     *      for(int i = 0; i < skills.Length; i++){
     *              GameObject obj = Instantiate(shopButton) as GameObject;
     *              obj.transform.SetParent(shop.transform);
     *              obj.transform.localPosition = new Vector3(-120 + (120 * i), -20, 0);
     *              ShopButtonManager manager = obj.GetComponent<ShopButtonManager>();
     *              manager.AttachHandler(this);
     *              manager.SetText(skills[i].GetName(), Skills.Attr(skills[i].GetID()).id + 1, skills[i].GetInfo(), skills[i].GetBody());
     *              addedButtons.Add(obj);
     *      }
     * }*/

    public void AddSkill(int i)
    {
        Skill s = (Skills.GetDefaultFromSkillInfo(Skills.GetSkillInfoFromID(i)));

        player.combat.AddSkill(s, Skills.Attr(s.GetID()).id);

        NetworkPlayerController netPlayer = player.combat.server.client
                                            .GetComponent <NetworkPlayerController>();

        DisplaySkills(netPlayer);
    }
Example #6
0
    public void Shop(int wave)
    {
        this.wave = wave;
        player.combat.SetHealth(player.combat.GetMaxHealth());
        player.combat.SetMana(player.combat.GetMaxMana());
        player.combat.SetAction(0f);
        List <Skill> missing = new List <Skill>();

        foreach (int i in CanUnlockSkills())
        {
            if (!player.combat.skillLibrary.Exists(x => x != null && Skills.Attr(x.GetID()).id == i))
            {
                missing.Add(Skills.GetDefaultFromSkillInfo(Skills.GetSkillInfoFromID(i)));
            }
        }
        NetworkPlayerController netPlayer = player.combat.server.client
                                            .GetComponent <NetworkPlayerController>();

        //missing.TrimExcess ();
        if (missing.Count == 0)
        {
            DisplaySkills(netPlayer);
            //map.NextWave ();
        }
        else
        {
            while (missing.Count > 3)
            {
                missing.RemoveAt(Random.Range(0, missing.Count));
            }
            int[] ia = new int[missing.Count];
            for (int i = 0; i < missing.Count; i++)
            {
                ia[i] = Skills.Attr(missing[i].GetID()).id;
            }
            netPlayer.RpcDisplayShop(ia);

            //PresentSkills(missing.ToArray());
        }
    }
Example #7
0
    public void DisplayShop(int[] skills)
    {
        if (skills.Length == 0)
        {
            netPlayer.CmdEndShop(-1);
            return;
        }
        shop.SetActive(true);

        for (int i = 0; i < skills.Length; i++)
        {
            Skill skill = Skills.GetDefaultFromSkillInfo(
                Skills.GetSkillInfoFromID(skills[i]));
            GameObject obj = Instantiate(shopButton) as GameObject;
            obj.transform.SetParent(shop.transform);
            obj.transform.localPosition = new Vector3(-120 + (120 * i), -20, 0);
            ShopButtonManager manager = obj.GetComponent <ShopButtonManager>();
            manager.AttachHandler(this);
            manager.SetText(skill.GetName(), Skills.Attr(skill.GetID()).id + 1,
                            skill.GetInfo(), skill.GetBody());
            addedButtons.Add(obj);
        }
    }
Example #8
0
 public static SkillInfo GetSkillInfoFromTitle(string title)
 {
     return(GetSkillInfoFrom(x => Skills.Attr(x).title == title));
 }
Example #9
0
 public static SkillInfo GetSkillInfoFromID(int id)
 {
     return(GetSkillInfoFrom(x => Skills.Attr(x).id == id));
 }
Example #10
0
 public string GetName()
 {
     return(Skills.Attr(GetID()).title);
 }