Ejemplo n.º 1
0
    void Update()
    {
        int  chars   = GameMaster.instance.characters.Count;
        Rect dropPos = new Rect((Screen.width - chars * 221) / 2 + 6,
                                Screen.height / 2 - 160, chars * 189 + 32 * (chars - 1), 403);
        int      charIndex     = (int)(mousePos.x - dropPos.x - 32 * (chars - 1)) / 189;
        BaseChar takenFromChar = GameMaster.instance.
                                 characters[itemTakenFromChar];

        if (Input.GetKeyUp(KeyCode.Mouse0) && floatingItem != null)
        {
            floatingItem.State = ItemState.Positioned;

            if (dropPos.Contains(mousePos) && charIndex != itemTakenFromChar)
            {
                takenFromChar.Items.Bag.Remove(floatingItem);
                BaseChar givenToChar = GameMaster.instance.
                                       characters[charIndex];
                putInBag(floatingItem, givenToChar);
            }
            else if (!takenFromChar.Items.Bag.Contains(floatingItem))
            {
                putInBag(floatingItem, takenFromChar);
            }

            floatingItem      = null;
            Screen.showCursor = true;
        }
    }
Ejemplo n.º 2
0
    void OnGUI()
    {
        GUI.depth = 0;
        GUI.skin = skin;

        float width = 221 * GameMaster.instance.characters.Count;
        GUI.BeginGroup(new Rect(Screen.width/2 - width / 2, 
            Screen.height / 2 - 300, width, 600));
        
        for(int i = 0; i < GameMaster.instance.characters.Count; i++)
        {
            character = GameMaster.instance.characters[i];
            offset = i * 221;
            GUI.DrawTexture(new Rect(i * 221, 0, 221, 562), background);
            showCharInfo();
            showCharItems();
            showItemToggles();
        }
        GUI.DrawTextureWithTexCoords(new Rect(0, 562, width, 38), bottomPanel,
                new Rect((1024 - width) / 1024, 0, width / 1024, 1));
        showCloseBtn();
        GUI.EndGroup();
        showDraggedItem();
        showTooltip();
    }
Ejemplo n.º 3
0
    void Start()
    {
        characters = new Dictionary <BaseChar, charInfo>();
        for (int i = 0; i < GameMaster.instance.characters.Count; i++)
        {
            BaseChar   character = GameMaster.instance.characters[i];
            GameObject charGO    = character.gameObject;
            Vector3    charPos   = charGO.transform.position;
            Vector2    gridPos   = GridManager.instance.calcGridPos(charPos);
            Point      point     = new Point((int)(gridPos.x - (int)gridPos.y / 2),
                                             (int)gridPos.y);
            TileBehaviour tb = GridManager.instance.Board[point];
            if (character == GameMaster.instance.selectedChar)
            {
                tb.setAsOrigin();
            }
            int steps = character.
                        getSecondaryAttr((int)SecondaryAttrNames.Movement_Speed).Value;
            characters.Add(character, new charInfo(tb, steps));
        }
        foreach (var character in characters)
        {
            if (character.Key != GameMaster.instance.selectedChar)
            {
                character.Value.tileBeh.setAsImpassable();
            }
        }

        Messenger.AddListener("selectedCharChanged", selectedCharChanged);
        Messenger.AddListener("obstaclePositioned", obstaclePositioned);
        Messenger.AddListener("refreshWalkableTiles", findWalkable);
    }
Ejemplo n.º 4
0
 public void AddChar(int uniqueID, BaseChar ch)
 {
     if (!_registChar.ContainsKey(uniqueID))
     {
         _registChar.Add(uniqueID, ch);
     }
 }
Ejemplo n.º 5
0
    void selectedCharChanged()
    {
        BaseChar selectedChar = GameMaster.instance.selectedChar;

        if (enabled)
        {
            currentCamera.enabled = false;
            GameObject selectedCharGO = selectedChar.gameObject;
            if (selectedCharGO != null)
            {
                currentCamera = selectedCharGO.GetComponentInChildren <Camera>();
            }
            else
            {
                GameObject cameraGO = GameObject.Find("InventoryCamera");
                currentCamera = cameraGO.GetComponent <Camera>();
            }
            float x      = (Screen.width / 2 - 151f) / Screen.width;
            float y      = (Screen.height / 2 - 114f) / Screen.height;
            float width  = 278f / Screen.width;
            float height = 308f / Screen.height;
            Rect  rect   = new Rect(x, y, width, height);
            currentCamera.rect    = rect;
            currentCamera.enabled = true;
        }

        setItemSlotContent(selectedChar);
    }
Ejemplo n.º 6
0
    void showMaxPanel()
    {
        BaseChar selectedChar = GameMaster.instance.selectedChar;

        GUI.BeginGroup(new Rect(Screen.width / 2 - 400, Screen.height - 90,
                                800, 90));
        Texture2D panel;

        if (GameMaster.instance.inCombat)
        {
            panel = Helper.getImage("Panel/combat panel");
        }
        else
        {
            panel = Helper.getImage("Panel/Panel");
        }
        GUI.DrawTexture(new Rect(0, 0, 800, 90), panel);
        showMessages();
        showMaxPanelBtns();
        showItems(selectedChar);
        showBigButtons(selectedChar);
        showModes();
        if (GameMaster.instance.inCombat)
        {
            string stepsLeft = CombatManager.instance.stepsLeft.ToString();
            GUI.Label(new Rect(641, 31, 50, 51), stepsLeft, "stepsLeft");
        }

        GUI.EndGroup();
    }
Ejemplo n.º 7
0
 void setItemSlotContent(BaseChar selectedChar)
 {
     if (selectedChar.Items.Armor == null)
     {
         armorSlotContent = new GUIContent("Armor");
     }
     else
     {
         armorSlotContent = new GUIContent(selectedChar.Items.Armor.Image,
                                           GUIHelper.getInfo(selectedChar.Items.Armor));
     }
     if (selectedChar.Items.Slot1 == null)
     {
         item1SlotContent = new GUIContent("Primary Item");
     }
     else
     {
         item1SlotContent = new GUIContent(selectedChar.Items.Slot1.Image,
                                           GUIHelper.getInfo(selectedChar.Items.Slot1));
     }
     if (selectedChar.Items.Slot2 == null)
     {
         item2SlotContent = new GUIContent("Secondary Item");
     }
     else
     {
         item2SlotContent = new GUIContent(selectedChar.Items.Slot2.Image,
                                           GUIHelper.getInfo(selectedChar.Items.Slot2));
     }
 }
Ejemplo n.º 8
0
    private void Flame(Vector3 pos)
    {
        Map map = GameMng.Map.GetCurrentMap();

        for (int x = -1; x < 2; x++)
        {
            for (int y = -1; y < 2; y++)
            {
                Tile     tile = map._tiles[x + (int)pos.x, y + (int)pos.y];
                BaseChar ch   = GameMng.CharMng.GetChar(tile);
                //BaseChar ch = GameMng.Instance.GetChar(tile);
                FlameEffect effect = EffectMng.Instance.Pop("FlameEffect") as FlameEffect;
                Buff        buff   = new Buff("Flame", 5);
                Debug.Log(effect);
                if (ch != null)
                {
                    BuffMng.Instance.AddBuff(ch, buff);

                    effect.Count = 5;
                    effect.CallEvent(ch.transform.position);
                    effect.Parent(ch.transform);
                }
                else
                {
                    effect.Count = 1;
                    effect.CallEvent(map._tiles[x + (int)pos.x, y + (int)pos.y].transform.position);
                    Debug.Log(effect.Count);
                }
            }
        }
    }
Ejemplo n.º 9
0
    public BaseChar loadChar()
    {
        //GameObject pc = GameObject.Find("Player Character");
        BaseChar bcClass = new BaseChar();//pc.GetComponent<BaseChar>();

        bcClass.charName = PlayerPrefs.GetString("Char name");
        bcClass.weight   = PlayerPrefs.GetInt("Weight");
        bcClass.height   = PlayerPrefs.GetInt("Height");

        //Archetype loading is missing

        for (int i = 0; i < Enum.GetValues(typeof(AttrNames)).Length; i++)
        {
            bcClass.getAttr(i).baseValue = PlayerPrefs.
                                           GetInt((AttrNames)i + " Base Value");
        }

        string[]  skills    = PlayerPrefs.GetString("Skills").Split('|');
        SkillTree skillTree = bcClass.CharClass.SkillTree;

        foreach (string skill in skills)
        {
            skillTree.Skills[skill].Known = true;
        }

        return(bcClass);
    }
Ejemplo n.º 10
0
    public void saveChar(BaseChar character)
    {
        //GameObject pc = GameObject.Find("Player Character");
        BaseChar bcClass = character;//pc.GetComponent<BaseChar>();

        PlayerPrefs.SetString("Char name", bcClass.charName);
        PlayerPrefs.SetInt("Weight", bcClass.weight);
        PlayerPrefs.SetInt("Height", bcClass.height);

        PlayerPrefs.SetString("Class", bcClass.CharClass.Name);

        for (int i = 0; i < Enum.GetValues(typeof(AttrNames)).Length; i++)
        {
            PlayerPrefs.SetInt((AttrNames)i + " Base Value",
                               bcClass.getAttr(i).baseValue);
        }
        string skills = "";

        Class charClass = bcClass.CharClass;

        foreach (Skill skill in charClass.SkillTree.Skills.Values)
        {
            if (skill.Known)
            {
                skills += skill.Name + "|";
            }
        }

        PlayerPrefs.SetString("Skills", skills);
    }
Ejemplo n.º 11
0
    void OnGUI()
    {
        GUI.depth = 0;
        GUI.skin  = skin;

        float width = 221 * GameMaster.instance.characters.Count;

        GUI.BeginGroup(new Rect(Screen.width / 2 - width / 2,
                                Screen.height / 2 - 300, width, 600));

        for (int i = 0; i < GameMaster.instance.characters.Count; i++)
        {
            character = GameMaster.instance.characters[i];
            offset    = i * 221;
            GUI.DrawTexture(new Rect(i * 221, 0, 221, 562), background);
            showCharInfo();
            showCharItems();
            showItemToggles();
        }
        GUI.DrawTextureWithTexCoords(new Rect(0, 562, width, 38), bottomPanel,
                                     new Rect((1024 - width) / 1024, 0, width / 1024, 1));
        showCloseBtn();
        GUI.EndGroup();
        showDraggedItem();
        showTooltip();
    }
Ejemplo n.º 12
0
    public void findClosestPlayerChar(Tile tile, out BaseChar character,
                                      out Tile closestCharTile)
    {
        int  distance, curDistance;
        Tile curTile;

        character       = GameMaster.instance.selectedChar;
        closestCharTile = characters[character].tileBeh.tile;
        distance        = int.MaxValue;

        foreach (var c in characters)
        {
            c.Value.tileBeh.tile.Passable = true;
        }

        foreach (var entry in characters)
        {
            curTile     = entry.Value.tileBeh.tile;
            curDistance = PathFinder.FindPath(tile, curTile).ToList().Count;
            if (curDistance < distance)
            {
                distance        = curDistance;
                closestCharTile = curTile;
                character       = entry.Key;
            }
        }

        foreach (var c in characters)
        {
            if (c.Key != character)
            {
                c.Value.tileBeh.setAsImpassable();
            }
        }
    }
Ejemplo n.º 13
0
    void showItems(BaseChar selectedChar)
    {
        Inventory  inv = selectedChar.Items;
        GUIContent content;

        if (inv.ActiveSlot == ItemSlots.Slot1)
        {
            if (inv.Slot1 != null)
            {
                content = new GUIContent(inv.Slot1.Image, inv.Slot1.Name);
            }
            else
            {
                content = new GUIContent("Punch");
            }
        }
        else
        {
            if (inv.Slot2 != null)
            {
                content = new GUIContent(inv.Slot2.Image, inv.Slot2.Name);
            }
            else
            {
                content = new GUIContent("Kick");
            }
        }
        if (GUI.Button(new Rect(376, 10, 140, 71), content))
        {
        }
    }
Ejemplo n.º 14
0
    public static IEnumerator AddCharAsync(CharType charType, int tableIdx, Vector3 pos, Quaternion rot,
                                           Transform parent, BaseChar refChar = null)
    {
        if (charType == CharType.Hero)
        {
            string          modelPath = Game.m_dataMng.Get(TableType.HeroTable).ToS(tableIdx, "PREFAB");
            bool            load      = false;
            ResourceRequest request   = Resources.LoadAsync <BaseChar>(modelPath);

            while (!load)
            {
                if (request.isDone)
                {
                    load = true;
                }

                yield return(null);
            }

            BaseChar hero = Instantiate(request.asset as BaseChar, pos, rot, parent);
            refChar = hero;
            // 캐릭터에 대한 정보를 설정하는 코드가 차후 추가될 예정입니다.

            // 캐릭터 매니저에 생성된 캐릭터를 등록합니다.
            Game.m_charMng.Add(Game.CH_UNIQUEID, tableIdx, hero);
        }

        yield return(null);
    }
Ejemplo n.º 15
0
    private IEnumerator IEAttack(Vector2 diraction, int value)
    {
        _go.GetComponent <BaseChar>().IsDone = false;

        Vector2 start = _go.transform.position;

        // 방향 전환
        float dir = CalculateDir(start, diraction);

        _go.transform.localScale = new Vector3(dir, 1, 1);
        float delayTime = 0;

        // 애니메이션
        _go.GetComponent <Animator>().SetTrigger("Attack");

        while (delayTime < 0.5)
        {
            delayTime += Time.deltaTime;
            yield return(null);
        }

        BaseChar ch = GameMng.CharMng.GetChar(_tile);

        if (ch != null)
        {
            ch.Damage(value);
            GameMng.Sound.SfxPlay(_hitSound);
        }

        _go.GetComponent <BaseChar>().IsDone = true;
    }
Ejemplo n.º 16
0
    public void characterAttacked(BaseChar character)
    {
        charInfo ci = characters[character];

        ci.attacked           = true;
        characters[character] = ci;
    }
Ejemplo n.º 17
0
    void Awake()
    {
        if (instance != null)
        {
            characters   = instance.characters;
            selectedChar = instance.selectedChar;
            foreach (BaseChar character in characters)
            {
                character.LostHP = 0;
            }
            instantiateCharacters();
            Destroy(gameObject);
            return;
        }

        instance = this;
        DontDestroyOnLoad(this);

        characters = new List <BaseChar>();
        characters.Add(Characters.EricFrost);
        characters.Add(Characters.Jared);
        characters.Add(Characters.Thom);
        selectedChar = characters[0];

        instantiateCharacters();
    }
Ejemplo n.º 18
0
 public void showTooltip(BaseChar character)
 {
     enabled        = true;
     tooltipVisible = true;
     charName       = character.charName;
     curHP          = character.CurrentHP;
     maxHP          = character.CurrentHP + character.LostHP;
 }
Ejemplo n.º 19
0
 public void AddBuff(BaseChar ch, Buff buff)
 {
     if (!_buffChar.ContainsKey(ch))
     {
         _buffChar.Add(ch, new List <Buff>());
     }
     _buffChar[ch].Add(buff);
 }
Ejemplo n.º 20
0
    Vector3 getFollowersPos()
    {
        GameMaster GM           = GameMaster.instance;
        BaseChar   myChar       = GM.getCharByGO(gameObject);
        int        myNr         = GM.characters.IndexOf(myChar);
        int        leadersNr    = GM.characters.IndexOf(GM.selectedChar);
        int        partialPosNr = -1;

        if (myNr > leadersNr)
        {
            myNr--;
        }
        for (int i = myNr; i < myNr + 4; i++)
        {
            int posNr = i % 4;
            if (takenPos[posNr])
            {
                continue;
            }
            Vector3     pos  = posNrToCoord(posNr);
            NavMeshPath path = new NavMeshPath();
            navAgent.CalculatePath(pos, path);
            if (path.status == NavMeshPathStatus.PathComplete)
            {
                takenPos[posNr] = true;
                clearTakenPosIfAllFollowersGotPos();
                myPosNr = posNr;
                return(pos);
            }
            if (path.status == NavMeshPathStatus.PathPartial)
            {
                partialPosNr = posNr;
            }
        }

        if (partialPosNr != -1)
        {
            takenPos[partialPosNr] = true;
            clearTakenPosIfAllFollowersGotPos();
            myPosNr = partialPosNr;
            return(posNrToCoord(partialPosNr));
        }

        for (int i = myNr; i < myNr + 4; i++)
        {
            int posNr = i % 4;
            if (!takenPos[posNr])
            {
                takenPos[posNr] = true;
                clearTakenPosIfAllFollowersGotPos();
                myPosNr = posNr;
                return(posNrToCoord(posNr));
            }
        }

        return(Vector3.zero);
    }
Ejemplo n.º 21
0
    public void charMoved()
    {
        BaseChar selectedChar     = GameMaster.instance.selectedChar;
        charInfo selectedCharInfo = characters[selectedChar];

        selectedCharInfo.tileBeh = GridManager.instance.originTileTB;
        characters[selectedChar] = selectedCharInfo;
        findWalkable();
    }
Ejemplo n.º 22
0
    void SplitSingle()
    {
        int refx = 0;// (int) winrect.x;
        int refz = 30;

        foreach (BaseGroup gb in grplist)
        {
            gb.Split();
            if (gb.type == (int)ENUM_TPMIX_GROUPTYPE.GROUP_TEXT)
            {
                GroupStr gptxt = (GroupStr)gb;
                for (int i = 0; i < gptxt.txt_info.Length; i++)
                {
                    BaseChar p = new BaseChar();
                    p.txt       = gptxt.txt_info.Substring(i, 1);
                    guitxt.text = p.txt;
                    int fw = (int)guitxt.GetScreenRect().width;
                    int fz = (int)guitxt.GetScreenRect().height + row * 2;
                    //refz += fz;
                    p.pr = new Rect(refx, refz, fw, fz);
                    gptxt.objlist.Add(p);

                    if (refx + fw >= winrect.x + winrect.width - 5)
                    {
                        refx  = 0;
                        refz += Mathf.Max(fz, linehei);
                    }
                    else
                    {
                        refx += fw;
                    }
                }
            }
            else if (gb.type == (int)ENUM_TPMIX_GROUPTYPE.GROUP_PIC)
            {
                GroupIco    gico = (GroupIco)gb;
                BasePicture p    = new BasePicture();
                gb.objlist.Add(p);
                string imgidx = gico.txt_info.Substring(1, gico.txt_info.Length - 2);
                p.ico = image[int.Parse(imgidx) % image.Length];
                int fw = p.ico.width;
                int fz = p.ico.height;
                p.pr = new Rect(refx, refz, fw, fz);
                if (refx + fw >= winrect.x + winrect.width - 5)
                {
                    refx  = 0;
                    refz += Mathf.Max(fz, linehei);
                }
                else
                {
                    refx += fw;
                }
            }
        }
    }
Ejemplo n.º 23
0
    void putInBag(Item item, BaseChar character)
    {
        foreach (Item i in character.Items.Bag)
        {
            if (i.Name.Equals(item.Name) && i != floatingItem)
            {
                i.Quantity++;
                return;
            }
        }

        character.Items.Bag.Add(item);
    }
Ejemplo n.º 24
0
 void showHeader(BaseChar selectedChar)
 {
     GUI.Label(new Rect(360, 5, 100, 20), "Skill Tree", "Title");
     int skillPoints = selectedChar.CharClass.SkillTree.SkillPoints;
     GUI.Label(new Rect(650, 10, 150, 20), "Skill Points: " + skillPoints, 
         "Skill Points");
     GUI.DrawTexture(new Rect(310, 38, 45, 50), selectedChar.Image, 
         ScaleMode.ScaleToFit, true);
     GUI.Label(new Rect(369, 35, 150, 20), selectedChar.charName);
     GUI.Label(new Rect(369, 55, 150, 20),
         "Class: " + selectedChar.CharClass.Name);
     GUI.Label(new Rect(369, 75, 150, 20), "Level: " + selectedChar.level);
 }
Ejemplo n.º 25
0
    public BaseChar GetChar(Tile tile)
    {
        BaseChar ch = null;

        foreach (var iter in _registChar)
        {
            if (iter.Value != null && iter.Value.NotifyPosition() == tile.Position)
            {
                ch = iter.Value;
            }
        }
        return(ch);
    }
Ejemplo n.º 26
0
    private void ClearBuff(string name, BaseChar ch)
    {
        switch (name)
        {
        case "Flame": break;

        case "Freeze": DeFreeze(ch); break;

        case "Invisibility": DeInvisibility(ch); break;

        case "Vision": DeVision(ch); break;
        }
    }
Ejemplo n.º 27
0
    private void EffectTick(string name, BaseChar ch)
    {
        switch (name)
        {
        case "Flame": Flame(ch); break;

        case "Freeze": Freeze(ch); break;

        case "Invisibility": Invisibility(ch); break;

        case "Vision": Vision(ch); break;
        }
    }
Ejemplo n.º 28
0
    void showHeader(BaseChar selectedChar)
    {
        GUI.Label(new Rect(360, 5, 100, 20), "Skill Tree", "Title");
        int skillPoints = selectedChar.CharClass.SkillTree.SkillPoints;

        GUI.Label(new Rect(650, 10, 150, 20), "Skill Points: " + skillPoints,
                  "Skill Points");
        GUI.DrawTexture(new Rect(310, 38, 45, 50), selectedChar.Image,
                        ScaleMode.ScaleToFit, true);
        GUI.Label(new Rect(369, 35, 150, 20), selectedChar.charName);
        GUI.Label(new Rect(369, 55, 150, 20),
                  "Class: " + selectedChar.CharClass.Name);
        GUI.Label(new Rect(369, 75, 150, 20), "Level: " + selectedChar.level);
    }
Ejemplo n.º 29
0
    void OnTriggerEnter(Collider collider)
    {
        BaseChar selectedChar = GameMaster.instance.selectedChar;

        if (collider.gameObject == selectedChar.gameObject)
        {
            Messenger.RemoveAllListeners();
            Application.LoadLevelAsync("Arena");
            loadingText = GameObject.Find("Loading Text").guiText;
            loadingText.material.color = new Color(0, 56f / 255f, 168f / 255f);
            loadingText.enabled        = true;
            StartCoroutine(animateLoadingText());
        }
    }
Ejemplo n.º 30
0
    void getCamera()
    {
        BaseChar   selectedChar   = GameMaster.instance.selectedChar;
        GameObject selectedCharGO = selectedChar.gameObject;

        if (selectedCharGO != null)
        {
            currentCamera = selectedCharGO.GetComponentInChildren <Camera>();
        }
        else
        {
            GameObject cameraGO = GameObject.Find("InventoryCamera");
            currentCamera = cameraGO.GetComponent <Camera>();
        }
    }
Ejemplo n.º 31
0
    public bool shootAt(GameObject target, bool miss)
    {
        this.target = target;
        calcRotations();
        if (isTargetBlocked())
        {
            return(false);
        }
        BaseChar selectedChar = GameMaster.instance.selectedChar;

        CombatManager.instance.characterAttacked(selectedChar);
        rotation   = getRandomRotation(miss);
        isRotating = true;
        return(true);
    }
Ejemplo n.º 32
0
    private IEnumerator IEMovingObject(Tile tile)
    {
        _go.GetComponent <BaseChar>().IsDone = false;
        _go.GetComponent <Animator>().SetTrigger("Attack");

        Vector2 curr   = _go.transform.position;
        Vector2 target = tile.Position;

        _projectile.transform.position = curr;
        CalculateDir(curr, target);

        int x = (int)Mathf.Abs(curr.x - target.x);
        int y = (int)Mathf.Abs(curr.y - target.y);

        int moveCount = 0;

        if (x > y)
        {
            moveCount = x;
        }
        else
        {
            moveCount = y;
        }

        float elapsedTime = 0;
        float targetTime  = 1f;

        while (elapsedTime < targetTime)
        {
            elapsedTime += Time.deltaTime * moveSpeed / moveCount;
            _projectile.transform.position = Vector2.Lerp(curr, target, elapsedTime);
            yield return(null);
        }

        BaseChar ch = GameMng.CharMng.GetChar(tile);

        if (ch != null)
        {
            ch.Damage(_damageValue);
            GameMng.Sound.SfxPlay(_projectile.Data._itemSound);
        }

        // Projectile Object Pool push
        GameMng.Pool.ItemPush(_projectile.Data._name, _projectile);
        //PoolMng.Instance.ItemPush(_projectile.Data._name, _projectile);
        _go.GetComponent <BaseChar>().IsDone = true;
    }
Ejemplo n.º 33
0
    public void saveChar(BaseChar character)
    {
        //GameObject pc = GameObject.Find("Player Character");
        BaseChar bcClass = character;//pc.GetComponent<BaseChar>();
        PlayerPrefs.SetString("Char name", bcClass.charName);
        PlayerPrefs.SetInt("Weight", bcClass.weight);
        PlayerPrefs.SetInt("Height", bcClass.height);

        PlayerPrefs.SetString("Class", bcClass.CharClass.Name);

        for (int i = 0; i < Enum.GetValues(typeof(AttrNames)).Length; i++)
            PlayerPrefs.SetInt((AttrNames)i + " Base Value",
                               bcClass.getAttr(i).baseValue);
        string skills = "";

        Class charClass = bcClass.CharClass;
        foreach (Skill skill in charClass.SkillTree.Skills.Values)
            if (skill.Known)
                skills += skill.Name + "|";

        PlayerPrefs.SetString("Skills", skills);
    }
Ejemplo n.º 34
0
    public BaseChar loadChar()
    {
        //GameObject pc = GameObject.Find("Player Character");
        BaseChar bcClass = new BaseChar();//pc.GetComponent<BaseChar>();

        bcClass.charName = PlayerPrefs.GetString("Char name");
        bcClass.weight = PlayerPrefs.GetInt("Weight");
        bcClass.height = PlayerPrefs.GetInt("Height");

        //Archetype loading is missing

        for (int i = 0; i < Enum.GetValues(typeof(AttrNames)).Length; i++)
            bcClass.getAttr(i).baseValue = PlayerPrefs.
                GetInt((AttrNames)i + " Base Value");

        string[] skills = PlayerPrefs.GetString("Skills").Split('|');
        SkillTree skillTree = bcClass.CharClass.SkillTree;

        foreach (string skill in skills)
            skillTree.Skills[skill].Known = true;

        return bcClass;
    }
Ejemplo n.º 35
0
	void Awake()
	{
        if (instance != null)
        {
            characters = instance.characters;
            selectedChar = instance.selectedChar;
            foreach (BaseChar character in characters)
                character.LostHP = 0;
            instantiateCharacters();
            Destroy(gameObject);
            return;
        }

        instance = this;
        DontDestroyOnLoad(this);
        
        characters = new List<BaseChar>();
        characters.Add(Characters.EricFrost);
        characters.Add(Characters.Jared);
        characters.Add(Characters.Thom);
        selectedChar = characters[0];

        instantiateCharacters();
	}
Ejemplo n.º 36
0
Archivo: OSD.cs Proyecto: VicBoss/KR
 public void showTooltip(BaseChar character)
 {
     enabled = true;
     tooltipVisible = true;
     charName = character.charName;
     curHP = character.CurrentHP;
     maxHP = character.CurrentHP + character.LostHP;
 }
Ejemplo n.º 37
0
 public void characterAttacked(BaseChar character)
 {
     charInfo ci = characters[character];
     ci.attacked = true;
     characters[character] = ci;
 }
Ejemplo n.º 38
0
 public bool didCharacterAttack(BaseChar character)
 {
     return characters[character].attacked;
 }
Ejemplo n.º 39
0
Archivo: HUD.cs Proyecto: VicBoss/KR
 void showBigButtons(BaseChar selectedChar)
 {
     if (GUI.Button(new Rect(321, 4, 37, 38), "»", "nextItemBtn"))
     {
         Inventory inv = selectedChar.Items;
         int activeSlot = ((int)inv.ActiveSlot + 1) % 2;
         selectedChar.Items.ActiveSlot = (ItemSlots)activeSlot;
         Messenger<ItemSlots>.Broadcast("ItemSlotChanged",
             (ItemSlots)activeSlot);
     }
     if (GUI.Button(new Rect(321, 47, 37, 38), "M", "modeBtn"))
     {
         if (modes.Count != 0)
             activeMode = (activeMode + 1) % modes.Count;
     }
 }
Ejemplo n.º 40
0
    public void findClosestPlayerChar(Tile tile, out BaseChar character,
        out Tile closestCharTile)
    {
        int distance, curDistance;
        Tile curTile;
        character = GameMaster.instance.selectedChar;
        closestCharTile = characters[character].tileBeh.tile;
        distance = int.MaxValue;

        foreach (var c in characters)
            c.Value.tileBeh.tile.Passable = true;

        foreach(var entry in characters)
        {
            curTile = entry.Value.tileBeh.tile;
            curDistance = PathFinder.FindPath(tile, curTile).ToList().Count;
            if (curDistance < distance)
            {
                distance = curDistance;
                closestCharTile = curTile;
                character = entry.Key;
            }
        }

        foreach (var c in characters)
            if (c.Key != character)
                c.Value.tileBeh.setAsImpassable();
    }
Ejemplo n.º 41
0
 void setItemSlotContent(BaseChar selectedChar)
 {
     if (selectedChar.Items.Armor == null)
         armorSlotContent = new GUIContent("Armor");
     else
         armorSlotContent = new GUIContent(selectedChar.Items.Armor.Image,
             GUIHelper.getInfo(selectedChar.Items.Armor));
     if (selectedChar.Items.Slot1 == null)
         item1SlotContent = new GUIContent("Primary Item");
     else
         item1SlotContent = new GUIContent(selectedChar.Items.Slot1.Image,
             GUIHelper.getInfo(selectedChar.Items.Slot1));
     if (selectedChar.Items.Slot2 == null)
         item2SlotContent = new GUIContent("Secondary Item");
     else
         item2SlotContent = new GUIContent(selectedChar.Items.Slot2.Image,
             GUIHelper.getInfo(selectedChar.Items.Slot2));
 }
Ejemplo n.º 42
0
    void showCharacterInfo(BaseChar selectedChar)
    {
        GUIContent content;

        GUI.DrawTexture(new Rect(567, 29, 76, 84), selectedChar.Image, 
            ScaleMode.ScaleToFit, true);
        GUI.Label(new Rect(648, 29, 150, 20), selectedChar.charName, "title");
        GUI.Label(new Rect(648, 49, 150, 20), 
            "Class: " + selectedChar.CharClass.Name, "title");
        GUI.Label(new Rect(648, 69, 150, 20), "Level: " + selectedChar.level, 
            "title");

        for (int i = 0; i < selectedChar.getAttributes().Length; i++)
        {
            BaseStat attribute = selectedChar.getAttr(i);
            content = new GUIContent(attribute.Name, attribute.description);
            GUI.Label(new Rect(571, 115 + i * 17, 100, 23), content);
            GUI.Label(new Rect(676, 115 + i * 17, 30, 23), 
                attribute.Value.ToString());
        }

        int nrOfPrimaryAttr = System.Enum.GetValues(typeof(AttrNames)).Length;
        int offset = 128 + nrOfPrimaryAttr * 17;
        for (int i = 0; i < selectedChar.getSecondaryAttributes().Length; i++)
        {
            ModifiedStat secAttr = selectedChar.getSecondaryAttr(i);
            string attrName = secAttr.Name.Replace('_', ' ');
            content = new GUIContent(attrName, secAttr.description);
            GUI.Label(new Rect(571, offset + i * 18, 150, 23), content);
            if (i == (int)SecondaryAttrNames.Hit_Points)
            {
                GUI.Label(new Rect(715, offset + i * 18, 58, 23),
                    selectedChar.CurrentHP.ToString() + "/" +
                    secAttr.Value.ToString(), "AttrValues");
                offset += 23;
                Texture2D PBEmpty, PBFull;
                PBEmpty = Helper.getImage("Inventory/ProgressBarEmpty");
                PBFull = Helper.getImage("Inventory/ProgressBarFull");
                float totalHP = selectedChar.LostHP + selectedChar.CurrentHP;
                GUI.DrawTexture(new Rect(571, offset + i * 18, 204, 10),
                    PBEmpty, ScaleMode.ScaleAndCrop);
                GUI.DrawTextureWithTexCoords(new Rect(571, offset + i * 18,
                    204 * selectedChar.CurrentHP / totalHP, 10), PBFull,
                    new Rect(0, 0, selectedChar.CurrentHP / totalHP, 1));
                offset += 10;
                GUI.Label(new Rect(571, offset + i * 18, 150, 23),
                    "Experience");
                GUI.Label(new Rect(715, offset + i * 18, 58, 23),
                    selectedChar.Exp.ToString() + "/" +
                    selectedChar.nextLevelExp.ToString(), "AttrValues");
                offset += 23;
                GUI.DrawTexture(new Rect(571, offset + i * 18, 204, 10),
                    PBEmpty, ScaleMode.ScaleAndCrop);
                offset -= 3;
            }
            else
                GUI.Label(new Rect(715, offset + i * 18, 58, 23),
                    secAttr.Value.ToString(), "AttrValues");
        }
    }
Ejemplo n.º 43
0
 void showItemSlots(BaseChar selectedChar)
 {
     if (GUI.RepeatButton(new Rect(240, 447, 140, 100), armorSlotContent))
     {
         if (selectedChar.Items.Armor != null)
         {
             selectedChar.Items.Armor.State = ItemState.Floating;
             floatingItem = selectedChar.Items.Armor;
             selectedChar.Items.Armor = null;
             armorSlotContent = new GUIContent("Armor");
         }
     }
     if (GUI.RepeatButton(new Rect(399, 447, 190, 100), item1SlotContent))
     {
         if (selectedChar.Items.Slot1 != null)
         {
             selectedChar.Items.Slot1.State = ItemState.Floating;
             floatingItem = selectedChar.Items.Slot1;
             selectedChar.Items.Slot1 = null;
             item1SlotContent = new GUIContent("Primary Item");
             Messenger<ItemSlots>.Broadcast("ItemSlotChanged", 
                 ItemSlots.Slot1);
         }
     }
     if (GUI.RepeatButton(new Rect(593, 447, 190, 100), item2SlotContent))
     {
         if (selectedChar.Items.Slot2 != null)
         {
             selectedChar.Items.Slot2.State = ItemState.Floating;
             floatingItem = selectedChar.Items.Slot2;
             selectedChar.Items.Slot2 = null;
             item2SlotContent = new GUIContent("Secondary Item");
             Messenger<ItemSlots>.Broadcast("ItemSlotChanged", 
                 ItemSlots.Slot2);
         }
     }
 }
Ejemplo n.º 44
0
    void putInBag(Item item, BaseChar character)
    {
        foreach (Item i in character.Items.Bag)
            if (i.Name.Equals(item.Name) && i != floatingItem)
            {
                i.Quantity++;
                return;
            }

        character.Items.Bag.Add(item);
    }
Ejemplo n.º 45
0
    void showItems(BaseChar selectedChar)
    {
        GUIContent content;
        RectOffset btnOffset = skin.FindStyle("Button").padding;
        int padding = btnOffset.top + btnOffset.bottom;
        int totalHeight = 0;
        foreach (Item item in selectedChar.Items.Bag)
        {
            if (selectedToggle == Toggle.Weapons && !(item is Weapon))
                continue;
            if (selectedToggle == Toggle.MedicineAndArmor &&
                !(item is Medication || item is Armor))
                continue;
            if (selectedToggle == Toggle.Keys && !(item is Key))
                continue;
            if (item.State != ItemState.Positioned)
                continue;
            totalHeight += item.Image.height + padding;
        }
        
        scrollPos = GUI.BeginScrollView(new Rect(11, 78, 212, 475), scrollPos,
            new Rect(0, 0, 192, totalHeight));
        int offset = 0;
        foreach(Item item in selectedChar.Items.Bag)
        {
            if (selectedToggle == Toggle.Weapons && !(item is Weapon))
                continue;
            if (selectedToggle == Toggle.MedicineAndArmor &&
                !(item is Medication || item is Armor))
                continue;
            if (selectedToggle == Toggle.Keys && !(item is Key))
                continue;
            
            //Workaround for RepeatButton bug...
            if (item.State != ItemState.Positioned)
                content = new GUIContent(new Texture2D(0, 0));
            else
                content = new GUIContent(item.Image, GUIHelper.getInfo(item));

            if (GUI.RepeatButton(new Rect(0, offset, 192, 
                item.Image.height + padding), content))
            {
                if (floatingItem == null)
                {
                    if (item.Quantity > 1)
                    {
                        Item clone = item.Clone();
                        clone.Quantity = 1;
                        clone.State = ItemState.Floating;
                        item.Quantity--;
                        floatingItem = clone;
                    }
                    else
                    {
                        item.State = ItemState.Floating;
                        floatingItem = item;
                    }
                }
            }

            if (item.State == ItemState.Positioned)
            {
                if (item.Quantity > 1)
                    GUI.Label(new Rect(0, offset, 192, item.Image.height + 
                        padding), item.Quantity.ToString(), "quantity");
                offset += item.Image.height + padding;
            }
        }
        GUI.EndScrollView();
    }
Ejemplo n.º 46
0
Archivo: HUD.cs Proyecto: VicBoss/KR
    void showItems(BaseChar selectedChar)
    {
        Inventory inv = selectedChar.Items;
        GUIContent content;

        if (inv.ActiveSlot == ItemSlots.Slot1)
        {
            if (inv.Slot1 != null)
                content = new GUIContent(inv.Slot1.Image, inv.Slot1.Name);
            else
                content = new GUIContent("Punch");
        }
        else
        {
            if (inv.Slot2 != null)
                content = new GUIContent(inv.Slot2.Image, inv.Slot2.Name);
            else
                content = new GUIContent("Kick");
        }
        if (GUI.Button(new Rect(376, 10, 140, 71), content)) { }
    }
Ejemplo n.º 47
0
 public Tile getCharactersTile(BaseChar character)
 {
     return characters[character].tileBeh.tile;
 }
Ejemplo n.º 48
0
    void showSkills(BaseChar selectedChar)
    {
        SkillTree skillTree = selectedChar.CharClass.SkillTree;
        int width = SkillTrees.btnWidth;
        int height = SkillTrees.btnHeight;
        float x, y;
        foreach (var skillPos in skillTree.SkillPos)
        {
            x = skillPos.Value.x;
            y = skillPos.Value.y;
            Skill skill = skillPos.Key;
            GUIContent content = new GUIContent(skill.Name, getInfo(skill));
            bool dependenciesMet = true;
            foreach(string skillName in skill.Dependencies)
                if (!skillTree.Skills[skillName].Known)
                {
                    dependenciesMet = false;
                    break;
                }
            Color color = new Color();
            if (skill.Rank == skill.MaxRank || skillTree.SkillPoints == 0 || 
                !dependenciesMet)
                GUI.enabled = false;
            if (!GUI.enabled && skill.Known)
            {
                color = GUI.color;
                GUI.color = new Color(1, 1, 1, 2);
            }
            //Ignore right clicks and middle clicks
            if (Event.current.button > 0 
                && Event.current.type != EventType.Repaint 
                && Event.current.type != EventType.Layout)
                Event.current.Use();

            if (GUI.Button(new Rect(x, y, width, height), content))
            {
                skill.Known = true;
                skill.Rank++;
                skillTree.SkillPoints--;
                if (skill.Name.Equals("Hermes Style") && selectedChar.
                    CharClass.SkillTree.Skills["Knife Master"].Known)
                {
                    skill.Bonuses[BonusType.Attack] = -30;
                    skill.Bonuses[BonusType.nrOfHits] = 3;
                }
                else if (skill.Name.Equals("Knife Master") && selectedChar.
                    CharClass.SkillTree.Skills["Hermes Style"].Known)
                {
                    Skill hermesStyle = selectedChar.
                        CharClass.SkillTree.Skills["Hermes Style"];
                    hermesStyle.Bonuses[BonusType.Attack] = -30;
                    hermesStyle.Bonuses[BonusType.nrOfHits] = 3;
                }

                Messenger<ItemSlots>.Broadcast("ItemSlotChanged",
                    selectedChar.Items.ActiveSlot);
            }
            x = x + width - tick.width - 2;
            y = y + height - tick.height - 2;
            for (int i = 0; i < skill.Rank; i++)
                GUI.DrawTexture(new Rect(x - i * (tick.width - 2), y,
                    tick.width, tick.height), tick);
            if (!GUI.enabled && skill.Known)
                GUI.color = color;
            GUI.enabled = true;
        }
    }
Ejemplo n.º 49
0
	public ModifiedStat(string name, BaseChar character): base(name) 
    {
        myChar = character;
        modifyingAttributes = new List<ModAttribute>();
    }