示例#1
0
    void OnItemClick(GameObject obj)
    {
        if (UiManager.Instance.isWindowShowByName("skillInfoWindow"))
        {
            return;
        }
        ButtonSkill button = obj.GetComponent <ButtonSkill> ();

        window.OnItemSelect(roleView.card, button.skillData);
    }
示例#2
0
        public void ButtonSkillTest()
        {
            Skill       skill       = new Attack();
            ButtonSkill buttonSkill = new ButtonSkill(skill);

            Skill expected = skill;
            Skill actual   = buttonSkill.Skill;

            Assert.AreEqual <Skill>(expected, actual);
            Assert.AreSame(expected, actual);
        }
示例#3
0
    void createLearnedButton(int type, int index)
    {
        GameObject  m      = Create3Dobj("ui/skillButton").obj;
        ButtonSkill button = m.GetComponent <ButtonSkill> ();

        button.fatherWindow         = this;
        button.transform.parent     = contentLearnedSkills.transform;
        button.transform.localScale = Vector3.one;
        button.name = "skillButton_" + StringKit.intToFixString(index);
        button.initSkillData(null, ButtonSkill.STATE_CANLEARN, type);
        ButtonLearnedSkills.Add(button);
    }
示例#4
0
        public static void Init(MenuBoss boss)
        {
            SkillTree.Init(boss.bossType);


            tutorial_state = TutorialState.BuySkill;

            selectedBoss = boss;
            skilltree    = SkillTree.skilltrees[selectedBoss.bossType];

            selectedBoss.MoveTo(new Vector2(0, 0));
            selectedBoss.idle();
            Console.WriteLine("" + Text.fonts.Keys.ToString());
            Console.Out.Flush();
            var test = Text.fonts;

            zeroAvailableRooms();
            UpgradeMenu.rerollRooms();

            selectedSkillSwapButton = new ButtonSkill();
            for (int x = 0; x < SelectedSkills.Length; x++)
            {
                SelectedSkills[x]             = new ButtonSkill();
                SelectedSkills[x].b           = new Button(Button.buttonPic, (int)baseSelectedSkillButtonPos.X, (int)baseSelectedSkillButtonPos.Y + 60 * x, 200, 50);
                SelectedSkills[x].b.text.font = Text.fonts["6809Chargen-12"];
                SelectedSkills[x].b.UpdateText("NONE");
            }

            hovertextpos  = new Vector2(30, 150);
            hovertext     = new Text("", new Vector2(hovertextpos.X + 10, hovertextpos.Y + 10), Text.fonts["RetroComputer-12"]);
            hovertextRect = new Rectangle((int)hovertextpos.X, (int)hovertextpos.Y, 500, 600);
            //250 x 150
            hovertextbackground = BattleManager.hovertextbackground;

            Vector2 statspos = new Vector2(30, boss.sTexture.Height + 10);

            statsTitle     = new Text("Stats", statspos, Text.fonts["RetroComputer-18"]);
            statsTitleRect = new Rectangle((int)statspos.X - 10, (int)statspos.Y - 5, (int)statsTitle.getMeasurements(300).X + 10, (int)statsTitle.font.MeasureString(statsTitle.message).Y + 15);
            statsText      = new Text(BattleManager.boss.StatsToString(), new Vector2(statspos.X, statspos.Y - 70), Text.fonts["RetroComputer-12"]);;
            statsTextRect  = new Rectangle((int)statsText.position.X, (int)statsText.position.Y - 100, (int)statsText.getMeasurements(300).X + 10, (int)statsText.getMeasurements(300).Y + 10);
            statsText.changeMessage("");

            texts["gold"]           = new Text("Gold: " + Resources.gold, new Vector2(150, 0), Text.fonts["6809Chargen-24"], Color.White);
            texts["level"]          = new Text("Level: " + BattleManager.boss.level, new Vector2(150, 50), Text.fonts["6809Chargen-24"], Color.White);
            texts["selectedskills"] = new Text("Selected Skills", new Vector2(baseSelectedSkillButtonPos.X, baseSelectedSkillButtonPos.Y - Text.fonts["6809Chargen-24"].MeasureString("Selected Skills").Y - 10), Text.fonts["6809Chargen-24"], Color.White);
            texts["skilltext"]      = new Text("Skills", new Vector2(baseSkillButtonPos.X + 100, baseSkillButtonPos.Y - 50), Text.fonts["6809Chargen-24"], Color.White);
            texts["roomtext"]       = new Text("Rooms", new Vector2(baseRoomButtonPos.X, baseRoomButtonPos.Y - 50), Text.fonts["6809Chargen-24"], Color.White);
        }
示例#5
0
 void moveToLearn(ButtonSkill button)
 {
     if (button.skillData == null)
     {
         return;
     }
     foreach (ButtonSkill each in ButtonLearnedSkills)
     {
         //如果是空而且类型同,才能转移过去
         if (each.skillType == button.skillData.getSkillStateType() && each.skillData == null)
         {
             button.gameObject.SetActive(false);
             contentCanLearnSkills.repositionNow = true;
             each.initSkillData(button.skillData, ButtonSkill.STATE_LEARNED);
             each.owner = button.owner;
             break;
         }
     }
 }
示例#6
0
    void removeFromLearn(ButtonSkill button)
    {
        Skill data = button.skillData;

        if (data == null)
        {
            return;
        }

        button.initSkillData(null, ButtonSkill.STATE_CANLEARN, button.skillData.getSkillStateType());
        button.owner = null;
        foreach (ButtonSkill each in allButtonSkills)
        {
            if (each.skillData == data)
            {
                each.gameObject.SetActive(true);
                contentCanLearnSkills.repositionNow = true;
                break;
            }
        }
    }
示例#7
0
 void OnItemLongPass(ButtonSkill button)
 {
     UiManager.Instance.openDialogWindow <SkillInfoWindow>((win) => {
         win.Initialize(button.skillData, roleView.card);
     });
 }
示例#8
0
    void initAllButtons()
    {
        List <chooseSkill> allSkills = new       List <chooseSkill> ();

        //得主人技能
        Skill[] aSkills = role.getAttrSkills();
        Skill[] mSkills = role.getSkills();
        Skill[] bSkills = role.getBuffSkills();

        //得祭品技能
        Skill[] aSkills2 = offering.getAttrSkills();
        Skill[] mSkills2 = offering.getSkills();
        Skill[] bSkills2 = offering.getBuffSkills();


        if (role.uid == UserManager.Instance.self.mainCardUid)
        {
            //只有主卡可以学主技能和被动技能
            if (mSkills != null)
            {
                foreach (Skill each in mSkills)
                {
                    allSkills.Add(new chooseSkill(role, each));
                }
            }
            if (mSkills2 != null)
            {
                foreach (Skill each in mSkills2)
                {
                    allSkills.Add(new chooseSkill(offering, each));
                }
            }

            if (bSkills != null)
            {
                foreach (Skill each in bSkills)
                {
                    allSkills.Add(new chooseSkill(role, each));
                }
            }
            if (bSkills2 != null)
            {
                foreach (Skill each in bSkills2)
                {
                    allSkills.Add(new chooseSkill(offering, each));
                }
            }
        }

        if (aSkills != null)
        {
            foreach (Skill each in aSkills)
            {
                allSkills.Add(new chooseSkill(role, each));
            }
        }
        if (aSkills2 != null)
        {
            foreach (Skill each in aSkills2)
            {
                allSkills.Add(new chooseSkill(offering, each));
            }
        }

        allSkillsNorep = new List <chooseSkill> ();

        //如果有相同sid的技能 .选最高级那个
        foreach (chooseSkill each in allSkills)
        {
            //确认新队列里没有这种技能
            bool has = false;
            foreach (chooseSkill repEach in allSkillsNorep)
            {
                if (each.skill.sid == repEach.skill.sid)
                {
                    has = true;
                    break;
                }
            }
            if (has == true)
            {
                continue;
            }

            //老队列中找出最高级的这种技能
            chooseSkill maxSkill = each;
            foreach (chooseSkill each2 in allSkills)
            {
                if (each.skill.sid == each2.skill.sid && each2.skill.getLevel() > maxSkill.skill.getLevel())
                {
                    maxSkill = each2;
                }
            }

            allSkillsNorep.Add(maxSkill);
        }



        allButtonSkills = new List <ButtonSkill> ();

        for (int i = 0; i < allSkillsNorep.Count; i++)
        {
            chooseSkill each   = allSkillsNorep [i];
            GameObject  m      = Create3Dobj("ui/skillButton").obj;
            ButtonSkill button = m.GetComponent <ButtonSkill> ();
            button.fatherWindow         = this;
            button.transform.parent     = contentCanLearnSkills.transform;
            button.transform.localScale = Vector3.one;
            button.name = "skillButton_" + i;
            button.initSkillData(each.skill, ButtonSkill.STATE_LEARNED);
            button.owner            = each.card;
            button.useInSkillChoose = true;
            allButtonSkills.Add(button);
        }

        contentCanLearnSkills.repositionNow = true;

        //下面初始化主卡可学技能的按钮:

        int[] max       = role.getSkillMaxSlot();
        int   bSkillmax = max [0];
        int   mSkillmax = max [1];
        int   aSkillmax = max [2];

        learnedSkills       = new List <Skill> ();
        ButtonLearnedSkills = new List <ButtonSkill> ();

        int index = 0;

        for (int i = 0; i < mSkillmax; i++)
        {
            index += 1;
            createLearnedButton(SkillStateType.ACTIVE, index);
            learnedSkills.Add(null);
        }

        for (int i = 0; i < bSkillmax; i++)
        {
            index += 1;
            createLearnedButton(SkillStateType.BUFF, index);
            learnedSkills.Add(null);
        }

        for (int i = 0; i < aSkillmax; i++)
        {
            index += 1;
            createLearnedButton(SkillStateType.ATTR, index);
            learnedSkills.Add(null);
        }

        contentLearnedSkills.repositionNow = true;
    }
示例#9
0
        public static LeaveMeAlone.GameState Update(GameTime g)
        {
            lastMouseState    = currentMouseState;
            currentMouseState = Mouse.GetState();
            int xpos = currentMouseState.X;
            int ypos = currentMouseState.Y;

            texts["gold"].changeMessage("Gold: " + Resources.gold);
            texts["level"].changeMessage("Level: " + BattleManager.boss.level);

            if (Mouse.GetState().LeftButton == ButtonState.Released)
            {
                left_click = false;
            }
            if (Mouse.GetState().RightButton == ButtonState.Released)
            {
                right_click = false;
            }

            if (BattleManager.boss.level < 2)
            {
                HandleTutorial();
            }

            foreach (Skill s in BattleManager.boss.skills)
            {
                skilltree.SkillButtons[s].text.color = Color.Black;
            }
            //gets things that haven't been bought and colors them
            foreach (Skill s in skilltree.SkillButtons.Keys.Except(BattleManager.boss.skills))
            {
                if (s.cost > Resources.gold || BattleManager.boss.level < s.level)
                {
                    skilltree.SkillButtons[s].text.color = Color.Red;
                }
                else
                {
                    skilltree.SkillButtons[s].text.color = Color.Blue;
                }
            }

            bool hovered = false;

            foreach (Skill s in skilltree.SkillButtons.Keys)
            {
                if (skilltree.SkillButtons[s].Intersects(currentMouseState.X, currentMouseState.Y))
                {
                    hovertext.changeMessage(s.name + ":\n" + s.description);
                    hovered = true;
                }
            }
            //Hover over Stats button
            if (statsTitleRect.Contains(currentMouseState.X, currentMouseState.Y))
            {
                statsText.changeMessage(BattleManager.boss.StatsToString());
                Vector2 statmeasurements = statsText.getMeasurements(300);
                statsText.position = new Vector2(statsTitle.position.X, statsTitleRect.Y + statsTitleRect.Height + 10);
                Console.WriteLine("statspos" + statsText.position.ToString());
                statsTextRect = new Rectangle((int)statsText.position.X - 10, (int)statsText.position.Y - 10, 300, (int)statmeasurements.Y + 10);
            }
            else
            {
                statsText.changeMessage("");
            }

            //perfect place for polymophism Chris
            hovered = false;
            foreach (Skill s in skilltree.SkillButtons.Keys)
            {
                if (skilltree.SkillButtons[s].Intersects(currentMouseState.X, currentMouseState.Y))
                {
                    StringBuilder sb = new StringBuilder();
                    sb.Append(s.name + ":");
                    if (BattleManager.boss.skills.Contains(s))
                    {
                        sb.Append(" (bought)");
                    }
                    else
                    {
                        sb.Append(" (Cost: " + s.cost + ")");
                    }
                    sb.Append("\nMana Cost: " + s.energy + "\nCooldown: " + s.cooldown + "\n");
                    sb.Append("\n" + s.description);
                    hovertext.changeMessage(sb.ToString());
                    hovered = true;
                }
            }
            foreach (ButtonRoom r in AvailableRooms)
            {
                if (r.b.Intersects(currentMouseState.X, currentMouseState.Y))
                {
                    StringBuilder sb = new StringBuilder();
                    sb.Append(r.r.name + ":");
                    if (boughtRooms.Contains(r.r))
                    {
                        sb.Append(" (bought)");
                    }
                    else
                    {
                        sb.Append(" (Cost: " + r.r.cost + ")");
                    }
                    sb.Append("\n" + r.r.description);
                    hovertext.changeMessage(sb.ToString());
                    hovered = true;
                }
            }
            if (hovered == false)
            {
                hovertext.changeMessage("");
            }
            selectedBoss.Update(g);
            //if (lastMouseState.LeftButton == ButtonState.Pressed && currentMouseState.LeftButton == ButtonState.Released)
            if (leftClicked())
            {
                //check if a room was clicked on
                for (int x = 0; x < AvailableRooms.Length; x++)
                {
                    if (BattleManager.boss.selected_rooms.Contains(AvailableRooms[x].r) == false && AvailableRooms[x].b.Intersects(currentMouseState.X, currentMouseState.Y) && AvailableRooms[x].r.level != -1)
                    {
                        if (AvailableRooms[x].r.cost < Resources.gold)
                        {
                            BattleManager.boss.selected_rooms.Add(AvailableRooms[x].r);
                            LairManager.addRoom(AvailableRooms[x]);
                            boughtRooms.Add(AvailableRooms[x].r);
                            Resources.gold -= AvailableRooms[x].r.cost;
                            tutorial_state  = TutorialState.Back;
                            buyingSound.Play();
                        }
                    }
                }
                //check the next button
                if (next.Intersects(currentMouseState.X, currentMouseState.Y))
                {
                    BattleManager.bossDefaultPosition();
                    LairManager.tutorial_state = LairManager.TutorialState.Build1;
                    return(LeaveMeAlone.GameState.Lair);
                }
                //check if we clicked on a skill
                foreach (Skill s in skilltree.SkillButtons.Keys)
                {
                    if (skilltree.SkillButtons[s].Intersects(currentMouseState.X, currentMouseState.Y))
                    {
                        Console.WriteLine("Got one!");
                        if (BattleManager.boss.skills.Contains(s) == false && BattleManager.boss.level >= s.level)
                        {
                            //if you have enough money, buy it
                            if (s.cost < Resources.gold)
                            {
                                BattleManager.boss.addSkill(s);
                                buyingSound.Play();
                                tutorial_state  = TutorialState.BuyRoom;
                                Resources.gold -= s.cost;
                                if (s == SkillTree.final_skill[BattleManager.boss.charType])
                                {
                                    LairManager.EndOfGame = true;
                                    LairManager.nextwaveBtn.rectangle.X = LeaveMeAlone.BackgroundRect.X;
                                    LairManager.nextwaveBtn.rectangle.Y = LeaveMeAlone.BackgroundRect.Height - 200;
                                }
                                //Console.WriteLine(BattleManager.boss.skills.Count);
                            }
                        }
                        else
                        {
                            //When a skill isn't selected to swap, it should be set to default(Skill)
                            if (selectedSkillSwapButton.s != default(Skill) && BattleManager.boss.skills.Contains(s) == true && BattleManager.boss.selected_skills.Contains(s) == false)
                            {
                                int index = BattleManager.boss.selected_skills.IndexOf(selectedSkillSwapButton.s);
                                BattleManager.boss.selected_skills[index] = s;
                                swappingSound.Play();
                                Console.WriteLine("swapped");
                            }
                        }
                        //Console.WriteLine(s+" pressed");
                    }
                }
                updateSelectedSkills();
                bool flag = false;
                for (int x = 0; x < SelectedSkills.Length; x++)
                {
                    var buttonStuff = SelectedSkills[x];

                    if (buttonStuff.b.Intersects(currentMouseState.X, currentMouseState.Y) && buttonStuff.s != null)
                    {
                        //already have a selected thing;
                        if (selectedSkillSwapButton.b != null)
                        {
                            selectedSkillSwapButton.b.selected = false;
                        }
                        flag = true;
                        selectedSkillSwapButton            = buttonStuff;
                        selectedSkillSwapButton.b.selected = true;
                        //Console.WriteLine("selected " + buttonStuff.s.name);
                    }
                }
                if (flag == false)
                {
                    if (selectedSkillSwapButton.b != null)
                    {
                        selectedSkillSwapButton.b.selected = false;
                    }
                    selectedSkillSwapButton = new ButtonSkill();;
                }
            }

            measurements = hovertext.getMeasurements(hovertextRect.Width - 15);
            if (xpos + hovertextRect.Width > LeaveMeAlone.WindowX - 20)
            {
                hovertextRect.X = LeaveMeAlone.WindowX - hovertextRect.Width - 20;
            }
            else
            {
                hovertextRect.X = currentMouseState.X + 10;
            }
            if (ypos + measurements.Y > LeaveMeAlone.WindowY - 20)
            {
                hovertextRect.Y = LeaveMeAlone.WindowY - (int)measurements.Y - 20;
            }
            else
            {
                hovertextRect.Y = currentMouseState.Y + 10;
            }
            return(LeaveMeAlone.GameState.Upgrade);
        }