コード例 #1
0
ファイル: GemPacket.cs プロジェクト: Etchavious/MapleServer2
    public static PacketWriter UnequipItem(GameSession session, GemSlot gemSlot)
    {
        PacketWriter pWriter = PacketWriter.Of(SendOp.Gem);

        pWriter.Write(GemMode.UnequipItem);
        pWriter.WriteInt(session.Player.FieldPlayer.ObjectId);
        pWriter.Write(gemSlot);

        return(pWriter);
    }
コード例 #2
0
ファイル: GemSlotUI.cs プロジェクト: thelegend831/teleports
    protected override UnlockableSlot GetSlot()
    {
        var heroData = Main.GameState.CurrentHeroData;

        if (heroData != null)
        {
            gemSlot = heroData.TeleportData.GetGemSlot(gemSlotID);
            return(gemSlot);
        }
        else
        {
            return(new UnlockableSlot());
        }
    }
コード例 #3
0
    public override void Init()
    {
        _player  = FindObjectOfType <Player>();
        _showGun = FindObjectOfType <ShowGun>();
        _showGun.Init();
        _gunInventoryBar = Helper.Find <RectTransform>(transform, "Bar");

        _damageGem = Helper.Find <GemSlot>(transform, GemPath + Damage);
        _powerGem  = Helper.Find <GemSlot>(transform, GemPath + Power);
        _speedGem  = Helper.Find <GemSlot>(transform, GemPath + Speed);

        _damageGem.Init(GemSlot.GemSlotType.Damage);
        _powerGem.Init(GemSlot.GemSlotType.Power);
        _speedGem.Init(GemSlot.GemSlotType.Speed);

        _damageSlotParent = Helper.Find <Transform>(transform, SlotPath + Damage);
        _powerSlotParent  = Helper.Find <Transform>(transform, SlotPath + Power);
        _speedSlotParent  = Helper.Find <Transform>(transform, SlotPath + Speed);

        _damageSockets = new GemSlot[5];
        _powerSockets  = new GemSlot[5];
        _speedSockets  = new GemSlot[5];

        _damageSockets = _damageSlotParent.GetComponentsInChildren <GemSlot>();
        _powerSockets  = _powerSlotParent.GetComponentsInChildren <GemSlot>();
        _speedSockets  = _speedSlotParent.GetComponentsInChildren <GemSlot>();

        for (int i = 0; i < _damageSockets.Length; i++)
        {
            _damageSockets[i].Init(GemSlot.GemSlotType.Damage, true);
            _powerSockets[i].Init(GemSlot.GemSlotType.Power, true);
            _speedSockets[i].Init(GemSlot.GemSlotType.Speed, true);
        }

        _buttons = GetComponentInChildren <Button>();
        _buttons.onClick.AddListener(() => { CloseUpdate(); });

        _originPos = _gunInventoryBar.transform.position;
        _gunInventoryBar.gameObject.SetActive(false);
    }
コード例 #4
0
        void DisplayCards()
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("Faction", EditorStyles.boldLabel, GUILayout.MaxWidth(190), GUILayout.MinWidth(90));
            GUILayout.Label("Name", EditorStyles.boldLabel, GUILayout.MaxWidth(160), GUILayout.MinWidth(60));
            GUILayout.Label("Level", EditorStyles.boldLabel, GUILayout.MaxWidth(140), GUILayout.MinWidth(40));
            GUILayout.Label("Pieces", EditorStyles.boldLabel, GUILayout.MaxWidth(150), GUILayout.MinWidth(50));
            GUILayout.Label("Gems", EditorStyles.boldLabel, GUILayout.MaxWidth(140), GUILayout.MinWidth(40));
            GUILayout.Label("Health", EditorStyles.boldLabel, GUILayout.MaxWidth(150), GUILayout.MinWidth(50));
            GUILayout.Label("", GUILayout.MinWidth(24));
            GUILayout.Label("", GUILayout.MinWidth(24));
            GUILayout.EndHorizontal();

            for (int i = 0; i < pcdb.Count; i++)
            {
                GUILayout.BeginHorizontal("Box");
                GUILayout.Label(pcdb.Get(i).CFaction.ToString(), "Box", GUILayout.MaxWidth(190), GUILayout.MinWidth(90));
                GUILayout.Label(pcdb.Get(i).CName, "box", GUILayout.MaxWidth(160), GUILayout.MinWidth(60));
                GUILayout.Label(pcdb.Get(i).CLevel.ToString(), "box", GUILayout.MaxWidth(140), GUILayout.MinWidth(40));
                GUILayout.Label(pcdb.Get(i).CPieces.ToString(), "box", GUILayout.MaxWidth(150), GUILayout.MinWidth(50));
                GUILayout.Label(pcdb.Get(i).GemSlotsCount.ToString(), "box", GUILayout.MaxWidth(140), GUILayout.MinWidth(40));
                GUILayout.Label(pcdb.Get(i).Health.ToString(), "box", GUILayout.MaxWidth(150), GUILayout.MinWidth(50));
                Texture2D editIcon = EditorGUIUtility.Load("Icons/EditIcon.png") as Texture2D;


                if (GUILayout.Button(editIcon, GUILayout.MinWidth(24), GUILayout.Height(24)))
                {
                    tempSlots[0] = new GemSlot();
                    tempSlots[1] = new GemSlot();
                    selectedItem = new PlayCard();

                    selectedItem = pcdb.Get(i);

                    switch (selectedItem.CFaction)
                    {
                    case (Factions.Egyptian):
                        for (int x = 0; x < _egyptianGods.Length; x++)
                        {
                            if (selectedItem.CName == _egyptianGods[x])
                            {
                                _cardNameIndex = x;
                            }
                        }
                        break;

                    case (Factions.Greek):
                        for (int x = 0; x < _greekGods.Length; x++)
                        {
                            if (selectedItem.CName == _greekGods[x])
                            {
                                _cardNameIndex = x;
                            }
                        }
                        break;

                    case (Factions.Nors):
                        for (int x = 0; x < _norsGods.Length; x++)
                        {
                            if (selectedItem.CName == _norsGods[x])
                            {
                                _cardNameIndex = x;
                            }
                        }
                        break;
                    }

                    if (selectedItem.GemSlotsCount > 0)
                    {
                        tempSlots[0] = selectedItem.GetGemSlot(0);
                    }
                    if (selectedItem.GemSlotsCount > 1)
                    {
                        tempSlots[1] = selectedItem.GetGemSlot(1);
                    }

                    _editSwitch = true;
                }



                Texture2D deleteIcon = EditorGUIUtility.Load("Icons/DeleteIcon.png") as Texture2D;
                if (GUILayout.Button(deleteIcon, GUILayout.MinWidth(24), GUILayout.Height(24)))
                {
                    if (EditorUtility.DisplayDialog("Delete Play Card", "Are you sure you want to delete " + pcdb.Get(i).CName + "!", "Delete", "Cancel"))
                    {
                        pcdb.DeleteCard(i);
                        tempSlots[0] = new GemSlot();
                        tempSlots[1] = new GemSlot();
                        selectedItem = new PlayCard();
                    }
                }
                GUILayout.EndHorizontal();
            }
        }
コード例 #5
0
 public void SetPrevSlot(GemSlot prev)
 {
     _prevGemSlot = prev;
 }
コード例 #6
0
ファイル: GemSelector.cs プロジェクト: elsamp/towers
 public void SetSelectedSlot(GemSlot slot)
 {
     selectedSlot = slot;
 }
コード例 #7
0
        void AddCardToDatabase()
        {
            GUILayout.Label("Add New Play Card", EditorStyles.boldLabel);
            selectedItem.CFaction = (Factions)EditorGUILayout.EnumPopup("Faction:", selectedItem.CFaction);

            switch (selectedItem.CFaction)
            {
            case (Factions.Egyptian):
                _cardNameIndex     = EditorGUILayout.Popup("Name: ", _cardNameIndex, _egyptianGods);
                selectedItem.CName = _egyptianGods [_cardNameIndex];
                break;

            case (Factions.Greek):
                _cardNameIndex     = EditorGUILayout.Popup("Name: ", _cardNameIndex, _greekGods);
                selectedItem.CName = _greekGods [_cardNameIndex];
                break;

            case (Factions.Nors):
                _cardNameIndex     = EditorGUILayout.Popup("Name: ", _cardNameIndex, _norsGods);
                selectedItem.CName = _norsGods [_cardNameIndex];
                break;
            }

            selectedItem.CLevel  = EditorGUILayout.IntSlider("Level:", selectedItem.CLevel, 0, 12);
            selectedItem.CDesc   = EditorGUILayout.TextArea(selectedItem.CDesc, GUILayout.Height(45));
            selectedItem.CPieces = EditorGUILayout.IntSlider("Number of pieces:", selectedItem.CPieces, 2, 12);


            selectedItem.GemSlotsCount = EditorGUILayout.IntSlider("Number of Gem Slots:", selectedItem.GemSlotsCount, 0, 2);

            if (selectedItem.GemSlotsCount > 0)
            {
                tempSlots[0].SlotShape = (GemSlot.SlotShapes)EditorGUILayout.EnumPopup("Slot#1 Shape:", tempSlots[0].SlotShape);
            }
            if (selectedItem.GemSlotsCount > 1)
            {
                tempSlots[1].SlotShape = (GemSlot.SlotShapes)EditorGUILayout.EnumPopup("Slot#2 Shape:", tempSlots[1].SlotShape);
            }


            GUILayout.BeginHorizontal();


            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();

            GUILayout.Space(68);
            selectedItem.AttackTop = EditorGUILayout.IntField(selectedItem.AttackTop, GUILayout.Width(40));

            GUILayout.EndHorizontal();

            GUILayout.Space(20);

            GUILayout.BeginHorizontal();

            selectedItem.AttackLeft = EditorGUILayout.IntField(selectedItem.AttackLeft, GUILayout.Width(40));
            GUILayout.Space(20);
            selectedItem.Health = EditorGUILayout.IntField(selectedItem.Health, GUILayout.Width(40), GUILayout.Height(40));
            GUILayout.Space(20);
            selectedItem.AttackRight = EditorGUILayout.IntField(selectedItem.AttackRight, GUILayout.Width(40));

            GUILayout.EndHorizontal();

            GUILayout.Space(20);

            GUILayout.BeginHorizontal();

            GUILayout.Space(68);
            selectedItem.AttackBottom = EditorGUILayout.IntField(selectedItem.AttackBottom, GUILayout.Width(40));

            GUILayout.EndHorizontal();

            GUILayout.EndVertical();

            GUILayout.EndHorizontal();



            //Add new Card Button
            if (_editSwitch)
            {
                if (GUILayout.Button("ِSave Card"))
                {
                    if (selectedItem == null)
                    {
                        return;
                    }

                    _cardNameIndex = 0;
                    tempSlots[0]   = new GemSlot();
                    tempSlots[1]   = new GemSlot();
                    selectedItem   = new PlayCard();
                    _editSwitch    = false;
                }
            }
            else
            {
                if (GUILayout.Button("ِAdd New Card"))
                {
                    if (selectedItem == null)
                    {
                        return;
                    }

                    for (int i = 0; i < selectedItem.GemSlotsCount; i++)
                    {
                        selectedItem.AddNewGemSlot(tempSlots[i]);
                    }

                    pcdb.AddNewCard(selectedItem);
                    _cardNameIndex = 0;
                    tempSlots[0]   = new GemSlot();
                    tempSlots[1]   = new GemSlot();
                    selectedItem   = new PlayCard();
                }
            }
        }
コード例 #8
0
 protected override UnlockableSlot GetSlot()
 {
     gemSlot = MainData.CurrentPlayerData.CurrentTeleportData.GetGemSlot(gemSlotID);
     return(gemSlot);
 }
コード例 #9
0
    public void GenerateSlots(string[] unitGems)
    {
        //number of gems slots should be the unit level
        uint numberOfGemsSlots = currentDescription.GetLevel();

        float widthOffset  = 0.8f;
        float heightOffset = -0.8f;

        uint nbGemsSlotsPerLine = numberOfGemsSlots;

        float y = 0.5f;

        if (numberOfGemsSlots > 5)
        {
            nbGemsSlotsPerLine = 5;
        }

        else
        {
            y = 0;
        }

        float baseX = 0 - (nbGemsSlotsPerLine - 1) * widthOffset / 2;
        float x     = baseX;

        //create gem slots
        for (int i = 1; i <= numberOfGemsSlots; i++)
        {
            //get RectTransform corners to start at the top left corner
            Vector3 position = new Vector3(x, y, 0) + UnitGemsZone.transform.position;

            x += widthOffset;

            GameObject slot = Instantiate(GemSlot, position, Quaternion.identity, UnitGemsZone.transform);
            slot.GetComponent <GemSlot>().IsUnitSlot = true;
            gemSlots.Add(slot);

            if (i != 0 && i % 5 == 0)
            {
                x  = baseX;
                y += heightOffset;
            }
        }

        //put unit owned gems in slots
        if (unitGems != null)
        {
            for (int i = 0; i < unitGems.Length; i++)
            {
                GameObject gemGameObject = Resources.Load("Gems/" + unitGems[i]) as GameObject;
                Vector3    position      = gemSlots[i].transform.position;
                GameObject newGem        = Instantiate(gemGameObject, position, Quaternion.identity, gemSlots[i].transform);

                GemSlot currentGemSlot = gemSlots[i].GetComponent <GemSlot>();
                currentGemSlot.Gem = newGem.GetComponent <Gem>();

                newGem.transform.GetChild(0).GetComponent <GemUI>().GemSlot = currentGemSlot;

                currentGemsDisplayed.Add(newGem);
                currentGems.Add(currentGemSlot.Gem);
            }
        }
    }