Esempio n. 1
0
    public void DefenseCmd(Transform chess)
    {
        CharacterProperty chessProperty = chess.GetComponent <CharacterProperty>();

        chessProperty.Attacked = true;
        chessProperty.Moved    = true;
        chessProperty.Defensed = true;
        //extending territory
        currentSelect.defenseCommand(chess);
        //update buff calculation and map material
        currentSelect.updateTerritoryMat();
        //currentSelect.updateAllCharactersPowers();
        currentSelect.DefenseNetwork();
        TurnFinished(chess);
    }
Esempio n. 2
0
    //Main GUI goes here
    void OnGUI()
    {
        GUI.depth           = 1;
        GUI.backgroundColor = Color.clear;
        GUI.color           = new Color(1.0f, 1.0f, 1.0f, _mainAlpha);

        if (MainGuiShow)
        {
            if (currentSelect.chess != null)
            {
                CurrentChess = currentSelect.chess;
            }
            if (CurrentChess != null)
            {
                CharacterProperty chessProperty = CurrentChess.GetComponent <CharacterProperty>();
                // move button
                if (chessProperty.Moved)
                {
                    GUI.enabled = false;
                }
                else
                {
                    GUI.enabled = true;
                }
                if (GUI.Button(posMoveBt, MoveTex))
                {
                    MainGuiFade = false;
                    SubGuiFade  = true;
                    moveShow    = true;
                    currentSelect.moveCommand(CurrentChess);
                    currentSelect.MoveCommandNetwork();
                }
                GUI.enabled = true;
                //roll over move button
                if (!chessProperty.Moved)
                {
                    if (posMoveBt.Contains(mousePos))
                    {
                        GUI.DrawTexture(posMoveBt, MoveTex);
                        GUI.Label(new Rect(btSize + leftMargin + 5, topMargin + 16, 100, 30), "move", mainStyle);
                    }
                }
                // summon button
                if (!chessProperty.Summoner)
                {
                    GUI.enabled = false;
                }
                else
                {
                    GUI.enabled = true;
                }

                if (GUI.Button(posSummonBt, SummonTex))
                {
                    MainGuiFade = false;
                    SubGuiFade  = true;
                    summonShow  = true;
                }
                GUI.enabled = true;
                //roll over summon button
                if (chessProperty.Summoner)
                {
                    if (posSummonBt.Contains(mousePos))
                    {
                        GUI.DrawTexture(posSummonBt, SummonTex);
                        GUI.Label(new Rect(btSize + leftMargin + 5, topMargin + segment + 16, 100, 30), "summon", mainStyle);
                    }
                }
                // Attack button
                if (chessProperty.Attacked || !attackable(CurrentChess))
                {
                    GUI.enabled = false;
                }
                else
                {
                    GUI.enabled = true;
                }

                if (GUI.Button(posAttackBt, AttackTex))
                {
                    MainGuiFade = false;
                    SubGuiFade  = true;
                    attackShow  = true;
                    currentSelect.attackCommand(CurrentChess);
                    currentSelect.AttackCommandNetwork();
                }
                GUI.enabled = true;
                //roll over attack button
                if (!chessProperty.Attacked && attackable(CurrentChess))
                {
                    if (posAttackBt.Contains(mousePos))
                    {
                        GUI.DrawTexture(posAttackBt, AttackTex);
                        GUI.Label(new Rect(btSize + leftMargin + 5, topMargin + segment * 2 + 16, 100, 30), "attack", mainStyle);
                    }
                }
                // skill button
                if (chessProperty.Activated)
                {
                    GUI.enabled = false;
                }
                else
                {
                    GUI.enabled = true;
                }
                if (GUI.Button(posSkillBt, SkillTex))
                {
                    MainGuiFade = false;
                    SubGuiFade  = true;
                    skillShow   = true;
                }
                GUI.enabled = true;
                //roll over skill button
                if (!chessProperty.Activated)
                {
                    if (posSkillBt.Contains(mousePos))
                    {
                        GUI.DrawTexture(posSkillBt, SkillTex);
                        GUI.Label(new Rect(btSize + leftMargin + 5, topMargin + segment * 3 + 16, 100, 30), "skill", mainStyle);
                    }
                }
                //Defense button

                if (chessProperty.Attacked)
                {
                    GUI.enabled = false;
                }
                else
                {
                    GUI.enabled = true;
                }

                if (GUI.Button(posDefenseBt, DefenseTex))
                {
                    chessProperty.Attacked = true;
                    chessProperty.Moved    = true;
                    //extending territory
                    currentSelect.defenseCommand(CurrentChess);
                    //update buff calculation and map material
                    currentSelect.updateTerritoryMat();
                    currentSelect.updateAllCharactersPowers();
                    currentSelect.DefenseNetwork();
                    TurnFinished(CurrentChess);
                }
                GUI.enabled = true;
                //roll over defense button
                if (!chessProperty.Attacked)
                {
                    if (posDefenseBt.Contains(mousePos))
                    {
                        GUI.DrawTexture(posDefenseBt, DefenseTex);
                        GUI.Label(new Rect(btSize + leftMargin + 5, topMargin + segment * 4 + 16, 100, 30), "defence", mainStyle);
                    }
                }
                // End turn button
                if (GUI.Button(posEndTurnBt, EndTurnTex))
                {
                    MainGuiFade = false;
                    //SubGuiFade = true;
                    chessProperty.Activated       = true;
                    chessProperty.Attacked        = true;
                    chessProperty.Moved           = true;
                    chessProperty.TurnFinished    = true;
                    CurrentChess.gameObject.layer = 10;
                    currentSelect.MoveToLayer(CurrentChess, 10);
                    currentSelect.EndTurnNetwork();
                }
                //roll over end turn button
                if (posEndTurnBt.Contains(mousePos))
                {
                    GUI.DrawTexture(posEndTurnBt, EndTurnTex);
                    GUI.Label(new Rect(btSize + leftMargin + 5, topMargin + segment * 5 + 13, 100, 30), "end turn", mainStyle);
                }
            }
        }
        GUI.color = new Color(1.0f, 1.0f, 1.0f, _subAlpha);

        if (moveShow)
        {
            GUI.DrawTexture(posMoveBt, MoveTex);
            GUI.Label(new Rect(btSize + leftMargin + 5, topMargin + 16, 100, 30), "move", mainStyle);
            if (Input.GetMouseButtonDown(0) && posMoveBt.Contains(mousePos))
            {
                Cancel      = true;
                MainGuiFade = true;
                SubGuiFade  = false;
                TurnFinished(CurrentChess);
            }
        }
        if (attackShow)
        {
            GUI.DrawTexture(posAttackBt, AttackTex);
            GUI.Label(new Rect(btSize + leftMargin + 5, topMargin + segment * 2 + 16, 100, 30), "attack", mainStyle);
            if (Input.GetMouseButtonDown(0) && posAttackBt.Contains(mousePos))
            {
                Cancel      = true;
                MainGuiFade = true;
                SubGuiFade  = false;
                TurnFinished(CurrentChess);
            }
        }
        if (summonShow)
        {
            Rect posSummonList = new Rect(posSummonBt.x + posSummonBt.width / 2, posSummonBt.y + posSummonBt.height / 2, 200.0f, 200.0f);
            GUI.DrawTexture(posSummonList, SubWindow);
            GUI.DrawTexture(posSummonBt, SummonTex);
            GUI.Label(new Rect(btSize + leftMargin + 5, topMargin + segment + 16, 100, 30), "summon", mainStyle);
            if (Input.GetMouseButtonDown(0) && posSummonBt.Contains(mousePos))
            {
                Cancel      = true;
                MainGuiFade = true;
                SubGuiFade  = false;
            }
            IList soldiers = new List <Transform>();
            if (CurrentChess.GetComponent <CharacterProperty>().Player == 1)
            {
                foreach (Transform gf in players.PlayerAChesses)
                {
                    if (!gf.GetComponent <CharacterProperty>().Summoner)
                    {
                        soldiers.Add(gf);
                    }
                }
            }
            else if (CurrentChess.GetComponent <CharacterProperty>().Player == 2)
            {
                foreach (Transform gf in players.PlayerBChesses)
                {
                    if (!gf.GetComponent <CharacterProperty>().Summoner)
                    {
                        soldiers.Add(gf);
                    }
                }
            }
            int seg = 0;
            foreach (Transform gf in soldiers)
            {
                CharacterProperty gfp = gf.GetComponent <CharacterProperty>();
                if (gfp.Ready && (gfp.summonCost <= currentSelect.player.GetComponent <ManaCounter>().Mana) && gfp.death)
                {
                    GUI.enabled = true;
                }
                else
                {
                    GUI.enabled = false;
                }
                Rect posGFBt = CreateGFBt(gf, seg);
                if (posGFBt.Contains(mousePos))
                {
                    infoUI.CreatedGFRollOver(gf, subStyle);
                }
                if (GUI.Button(posGFBt, "", subStyle))
                {
                    currentSelect.summonCommand(CurrentChess, gf);
                    //update network UI
                    currentSelect.SummonNetwork();
                }
                seg += 1;
            }
        }
        if (skillShow)
        {
            Rect posSkillsBt = new Rect(posSkillBt.x + posSkillBt.width / 2, posSkillBt.y + posSkillBt.height / 2, 200.0f, 100.0f);
            GUI.DrawTexture(posSkillsBt, SubWindow);
            GUI.DrawTexture(posSkillBt, SkillTex);
            GUI.Label(new Rect(btSize + leftMargin + 5, topMargin + segment * 3 + 16, 100, 30), "skill", mainStyle);
            if (Input.GetMouseButtonDown(0) && posSkillBt.Contains(mousePos))
            {
                Cancel      = true;
                MainGuiFade = true;
                SubGuiFade  = false;
            }
            Transform[] skills = CurrentChess.GetComponent <SkillSets>().Skills;
            int         seg    = 0;
            if (skills.Length > 0)
            {
                foreach (Transform skill in skills)
                {
                    if (currentSelect.player.GetComponent <ManaCounter>().Mana >= skill.GetComponent <SkillProperty>().SkillCost)
                    {
                        GUI.enabled = true;
                    }
                    else
                    {
                        GUI.enabled = false;
                    }
                    Rect skillBtRect = CreateSkillBt(skill, seg);
                    if (skillBtRect.Contains(mousePos))
                    {
                        ShowSkillInfo(skill);
                    }
                    if (GUI.Button(skillBtRect, "", subStyle))
                    {
                        currentSelect.SkillUINetwork();
                        if (!skill.GetComponent <SkillProperty>().NeedToSelect)
                        {
                            skill.GetComponent <SkillProperty>().GetRealSkillRate();
                            skill.GetComponent <SkillProperty>().PassSkillRate = MapHelper.Success(skill.GetComponent <SkillProperty>().SkillRate);
                            skill.GetComponent <SkillProperty>().ActivateSkill();
                            currentSelect.player.GetComponent <ManaCounter>().Mana   -= skill.GetComponent <SkillProperty>().SkillCost;
                            CurrentChess.GetComponent <CharacterProperty>().Activated = true;
                            currentSelect.AnimStateNetWork(CurrentChess, AnimVault.AnimState.skill);
                            SubGuiFade = false;
                            TurnFinished(CurrentChess);
                            //update network
                            currentSelect.SkillCmdNetwork(CurrentChess, skill);
                        }
                        else
                        {
                            currentSelect.skillCommand(skill);
                        }
                    }
                    seg        += 1;
                    GUI.enabled = true;
                }
            }
        }
    }