Exemplo n.º 1
0
Arquivo: Unit.cs Projeto: TaynaCT/PA1
        void Start()
        {
            Guid guid = Guid.NewGuid();

            gameObject.name = guid.ToString();

            if (PlayerID != null)
            {
                PlayerID.text = "none";
            }

            this.gameObject.GetComponent <SpriteRenderer>().sprite = UnitSprite;

            _actionMenu.SetActive(false);
            _isActionMenuActive    = false;
            this.gameObject.tag    = "Unit";
            _isSelected            = false;
            _lastPos               = transform.position;
            _inMovementRangeCoords = new List <Indice>();
            _itens        = new GameObject[3];
            _spriteRender = GetComponent <SpriteRenderer>();
            statsManager  = MainLoop.Instance().StatsManager;

            _movement  = 2;
            _atributes = new Atributes(50f, 0, 30, 0, 15, 10, 0.3f, 0.5f, 0.4f, 5);
            SetStatsValues();

            _class       = UnitClass.Archer;
            movementType = MovementType.Foot;
            //_owner = UnitOwner.Player;

            MainLoop.Instance().interfaceList.Add(this);
        }
Exemplo n.º 2
0
        public void ShowStats(int i)
        {
            //i = 0 hides stats, i = 1 shows stats
            if (i != 0)
            {
                i = 1;
                SetProgressBars();
            }
            else
            {
                Health.Text = "";
                Mana.Text   = "";
                LVL.Text    = "";
                XP.Text     = "";
            }
            Player.Opacity          = i;
            PlayerHealthBar.Opacity = i;
            PlayerImage.Opacity     = i;
            PlayerImageBox.Opacity  = i;
            PlayerManaBar.Opacity   = i;
            PlayerXPBar.Opacity     = i;
            EquipmentInfo.Opacity   = i;

            Atributes points = Stuff.FindCharacter(1).GetAtributes();

            if (i == 1)
            {
                InfoBox.Text = "Atributes:\n\nStrength: " + points.GetStrength()
                               + "\nVitality: " + points.GetVitality() + "\nAgility: " + points.GetAgility()
                               + "\nIntelligence: " + points.GetIntelligence() + "\nWillpower: " + points.GetWillpower()
                               + "\nLuck: " + points.GetLuck();
            }
            else
            {
                InfoBox.Text = "";
            }

            EquipmentSlots items = Stuff.FindCharacter(1).GetEquipment();

            for (int j = 1; j < 4; j++)
            {
                Image     itemImage = (Image)this.FindName("Item" + j);
                Rectangle rectangle = (Rectangle)this.FindName("Item" + j + "_Slot");
                if (j == 1)
                {
                    itemImage.Source = items.GetPrimary().GetSprite().Source;
                }
                else if (j == 2)
                {
                    itemImage.Source = items.GetSecondary().GetSprite().Source;
                }
                else
                {
                    itemImage.Source = items.GetArmor().GetSprite().Source;
                }
                itemImage.Opacity = i;
                rectangle.Opacity = i;
            }
        }
Exemplo n.º 3
0
    public static Atributes LoadAttribute(AtributeName name)
    {
        Atributes att = new Atributes();

        att.BaseValue = PlayerPrefs.GetInt(((AtributeName)name).ToString() + BASE_VALUE, 0);
        att.XptoLvL   = PlayerPrefs.GetInt(((AtributeName)name).ToString() + EXP_TO_LEVEL, Atributes.STARTING_EXP_COST);
        return(att);
    }
Exemplo n.º 4
0
 private void SetupPrimaryAttribute()
 {
     for (int cnt = 0; cnt < primaryAttribute.Length; cnt++)
     {
         primaryAttribute[cnt]      = new Atributes();
         primaryAttribute[cnt].Name = ((AtributeName)cnt).ToString();
     }
 }
Exemplo n.º 5
0
 public void DealDamge(Atributes character)
 {
     print(this.gameObject.GetComponent <Atributes>().avatarName + " is doing  damage");
     character.healt -= this.gameObject.GetComponent <Atributes>().DamageOutput;
     if (character.healt < 1)
     {
         character.Death();
     }
 }
Exemplo n.º 6
0
    private void SetFighter()
    {
        Atributes      attributes = fighter.GetComponent <Atributes>();
        CharacterClass charClass  = attributes.CharClass;

        Name.text  = fighter.Name;
        Level.text = "Lvl: " + attributes.Level.ToString();

        if (charClass == CharacterClass.Mage)
        {
            SetBar(BarType.Mana, ExtraBar);
        }
        else
        {
            SetBar(BarType.Stamina, ExtraBar);
        }
    }
Exemplo n.º 7
0
    // Update is called once per frame
    void Update()
    {
        if (fighter != null)
        {
            Atributes      attributes = fighter.GetComponent <Atributes>();
            CharacterClass charClass  = attributes.CharClass;

            SetBar(BarType.HP, HealthBar);
            if (charClass == CharacterClass.Mage)
            {
                SetBar(BarType.Mana, ExtraBar);
            }
            else
            {
                SetBar(BarType.Stamina, ExtraBar);
            }
        }
    }
Exemplo n.º 8
0
    private void SetAttacks()
    {
        foreach (var button in ChoiseButtons)
        {
            Destroy(button.gameObject);
        }
        ChoiseButtons.Clear();

        if (Fighter.Selected != null)
        {
            Atributes atributes = Fighter.Selected.Atributes;

            foreach (Attack attacks in atributes.Feats)
            {
                GameObject newButton = GameObject.Instantiate(ButtonPrefab);
                newButton.transform.SetParent(transform);
                Button button = newButton.GetComponent <Button>();
                button.onClick.AddListener(delegate { SelectedAttack(Fighter.Selected, attacks); });


                EventTrigger eventTrigger = newButton.GetComponent <EventTrigger>();
                EventTrigger.TriggerEvent enterTrigger = new EventTrigger.TriggerEvent();
                EventTrigger.TriggerEvent exitTrigger  = new EventTrigger.TriggerEvent();
                enterTrigger.AddListener(delegate { PointerEnter(Fighter.Selected, attacks, button.gameObject); });
                exitTrigger.AddListener(delegate { PointerExit(); });

                EventTrigger.Entry enterEntry = new EventTrigger.Entry()
                {
                    callback = enterTrigger,
                    eventID  = EventTriggerType.PointerEnter
                };
                EventTrigger.Entry exitEntry = new EventTrigger.Entry()
                {
                    callback = exitTrigger,
                    eventID  = EventTriggerType.PointerExit
                };

                eventTrigger.triggers.Add(enterEntry);
                eventTrigger.triggers.Add(exitEntry);
            }
        }
    }
Exemplo n.º 9
0
        public JsonResult LoadAttribute(int id)
        {
            var attribute = db.Atributes.Where(s => s.category_id == id).ToList();
            List <Atributes> listAttributes = new List <Atributes>();
            Atributes        tmp            = null;

            foreach (var item in attribute)
            {
                tmp               = new Atributes();
                tmp.atribute_id   = item.atribute_id;
                tmp.atribute_name = item.atribute_name;
                tmp.category_id   = item.category_id;
                listAttributes.Add(tmp);
            }
            return(Json(new
            {
                data = listAttributes,
                status = true
            }));
        }
Exemplo n.º 10
0
    public override void OnInspectorGUI()
    {
        Atributes myStats = (Atributes)target;

        DrawDefaultInspector();

        EditorGUILayout.Separator();

        EditorGUILayout.LabelField("Experience", myStats.Experience.ToString());
        EditorGUILayout.LabelField("Level", myStats.Level.ToString());

        EditorGUILayout.Separator();

        if (GUILayout.Button("Clear Experience"))
        {
            myStats.ClearExperience();
        }

        if (GUILayout.Button("Give Experience"))
        {
            myStats.GiveExperience(750);
        }
    }
Exemplo n.º 11
0
    public void SetCharacterInfo()
    {
        currentCharacter = GameObject.Find("Player");

        Atributes atributes = GameObject.FindObjectOfType<Atributes>();//currentCharacter.GetComponent<Atributes>();
        //TODO(FIXME)


        string atrbiuteText = string.Empty;
        string valueText = string.Empty;
        if (atributes.Strenght > 0)
        {
            atrbiuteText = atrbiuteText + "Strenght:";
            valueText = valueText + atributes.Strenght.ToString() + "/";
            if (atributes.GetExtraStrenght() > 0)
            {
                valueText = valueText + "<color=green>+" + atributes.GetExtraStrenght().ToString() + "</color>";
            }
            else if (atributes.GetExtraStrenght() < 0)
            {
                valueText = valueText + "<color=red>" + atributes.GetExtraStrenght().ToString() + "</color>";
            }
            else
            {
                valueText = valueText + "0";
            }
            atrbiuteText = atrbiuteText + "\n";
            valueText = valueText + "\n";
        }
        if (atributes.Dexterity > 0)
        {
            atrbiuteText = atrbiuteText + "Dexterity:";
            valueText = valueText + atributes.Dexterity.ToString() + "/";
            if (atributes.GetExtraDexterity() > 0)
            {
                valueText = valueText + "<color=green>+" + atributes.GetExtraDexterity().ToString() + "</color>";
            }
            else if (atributes.GetExtraDexterity() < 0)
            {
                valueText = valueText + "<color=red>" + atributes.GetExtraDexterity().ToString() + "</color>";
            }
            else
            {
                valueText = valueText + "0";
            }
            atrbiuteText = atrbiuteText + "\n";
            valueText = valueText + "\n";
        }
        if (atributes.Intelligent > 0)
        {
            atrbiuteText = atrbiuteText + "Intelligent:";
            valueText = valueText + atributes.Intelligent.ToString() + "/";
            if (atributes.GetExtraIntelligent() > 0)
            {
                valueText = valueText + "<color=green>+" + atributes.GetExtraIntelligent().ToString() + "</color>";
            }
            else if (atributes.GetExtraIntelligent() < 0)
            {
                valueText = valueText + "<color=red>" + atributes.GetExtraIntelligent().ToString() + "</color>";
            }
            else
            {
                valueText = valueText + "0";
            }
            atrbiuteText = atrbiuteText + "\n";
            valueText = valueText + "\n";
        }
        if (atributes.Magic > 0)
        {
            atrbiuteText = atrbiuteText + "Magic:";
            valueText = valueText + atributes.Magic.ToString() + "/";
            if (atributes.GetExtraMagic() > 0)
            {
                valueText = valueText + "<color=green>+" + atributes.GetExtraMagic().ToString() + "</color>";
            }
            else if (atributes.GetExtraMagic() < 0)
            {
                valueText = valueText + "<color=red>" + atributes.GetExtraMagic().ToString() + "</color>";
            }
            else
            {
                valueText = valueText + "0";
            }
            atrbiuteText = atrbiuteText + "\n";
            valueText = valueText + "\n";
        }

        string className = "Lvl " + atributes.Level.ToString() + " " + atributes.CharClass.ToString();

        AtributeValues.text = valueText;
        CharacterAttributes.text = atrbiuteText;
        CharacterName.text = currentCharacter.name;
        CharacterClass.text = className;

    }
Exemplo n.º 12
0
 public static void SaveAttributes(AtributeName name, Atributes att)
 {
     PlayerPrefs.SetInt(((AtributeName)name).ToString() + BASE_VALUE, att.AdjustedBaseValue);
     PlayerPrefs.SetInt(((AtributeName)name).ToString() + EXP_TO_LEVEL, att.XptoLvL);
 }
Exemplo n.º 13
0
    private void AddAttack(Attack attack)
    {
        GameObject     character = Menu.Instance.Character;
        Atributes      attribute = character.GetComponent <Atributes>();
        CharacterClass charClass = attribute.CharClass;

        FeatContainer feats = FightManager.Instance.Feats;

        if (attack.Class == charClass || attack.Class == CharacterClass.Any)
        {
            Sprite iconSprite = Resources.Load <Sprite>(attack.Icon);

            GameObject attackButton = GameObject.Instantiate(IconPrefab);

            attackButton.transform.SetParent(attacksGlg.transform);
            attackButton.transform.GetChild(0).GetComponent <Image>().sprite = iconSprite;
            attackButton.GetComponent <FeatSlot>().Feat = attack;
            attackButton.name = attack.Name;
            attackButton.transform.localScale = new Vector3(1f, 1f, 1f);


            if (Menu.Instance.Character.GetComponent <Atributes>().Feats.Contains(attackButton.GetComponent <FeatSlot>().Feat))
            {
                attackButton.GetComponent <FeatSlot>().Unlocked = true;
            }
            else
            {
                attackButton.GetComponent <FeatSlot>().Unlocked = false;
            }

            if (attack.MinLevel > attribute.Level)
            {
                attackButton.GetComponent <FeatSlot>().EnoughLevel = false;
            }
            else
            {
                attackButton.GetComponent <FeatSlot>().EnoughLevel = true;
            }


            ignore.Add(attack);

            foreach (var other in feats.Attacks)
            {
                if (other.Need == attack.ID && other != attack)
                {
                    AddArrow();
                    AddAttack(other);
                    if (!foundStage2)
                    {
                        foundStage2 = true;
                    }
                    else
                    {
                        foundStage3 = true;
                    }
                    break;
                }
            }
        }
    }
Exemplo n.º 14
0
 public ModifyingAtribute(Atributes att, float rat)
 {
     atribute = att;
     ratio    = rat;
 }