예제 #1
0
 public override void Init()
 {
     base.Init();
     layer    = GameLayer.Tips;
     instance = this;
     SetVisible(true);
 }
예제 #2
0
    //还没有处理装备满了的情况
    public bool AddEquip(Equip equip)
    {
        if (equip == null)
        {
            return(false);
        }
        int index = -1;

        for (int i = 0; i < equipBag.Length; i++)
        {
            if (equipBag[i] == null)
            {
                index       = i;
                equipBag[i] = equip;
                break;
            }
        }
        if (index != -1)
        {
            EventManager.ExecuteEvent(EventType.EquipUpdate, index);
            return(true);
        }
        else
        {
            WndTips.ShowTips("背包已满,装备获取失败!");

            return(false);
        }
    }
예제 #3
0
        public void Init(int time, int value)
        {
            wndTips = ViewManager.Get <WndTips>("WndTips");

            this.time = time;

            this.value = value;
        }
예제 #4
0
 public void OnClickRefresh()
 {
     if (playerModel.SetMoney(-refreshCost))
     {
         RefreshShopData();
     }
     else
     {
         WndTips.ShowTips("您的金币不足以刷新商店");
     }
 }
예제 #5
0
 void OnClickLoadGame(GameObject go)
 {
     if (SaveAndLoad.hasSaveFile)
     {
         LoadGame();
     }
     else
     {
         WndTips.ShowTips("您暂时没有存档,请点击开始游戏");
     }
     OnButtonClick(go);
 }
예제 #6
0
        protected override void OnFightStart(dynamic dy)
        {
            WndTips.ShowTips("我方所有角色闪避率增加10%");
            var roles = FightManager.instance.playerRoles;

            foreach (var role in roles)
            {
                if (role != null)
                {
                    role.missValue += 0.1f;
                }
            }
        }
예제 #7
0
    //获得新装备
    public bool AddEquip(Equip equip)
    {
        Equip curEquip = equips[equip.equipType];

        if (curEquip != null)
        {
            //curEquip.UnLoad(this);
            if (curEquip.level > equip.level)
            {
                WndTips.ShowTips("不可替换为低等级的装备!");
                return(false);
            }
            else
            {
                AudioManager.instance.PlayEffect(ConstConfig.UpEquip);

                EquipModel equipModel = ModelManager.Get <EquipModel>("EquipModel");

                curEquip.UnLoad(this);

                equipModel.AddEquip(curEquip);

                equips[equip.equipType] = equip;

                equip.Load(this);

                OnUpdateEquip?.Invoke();

                return(true);
            }
        }
        else if (equip.level > cost && isLevelEffect == true)
        {
            WndTips.ShowTips("装备等级不能低于角色品质.");
            return(false);
        }
        else
        {
            AudioManager.instance.PlayEffect(ConstConfig.UpEquip);

            equips[equip.equipType] = equip;

            equip.Load(this);

            OnUpdateEquip?.Invoke();

            return(true);
        }
        //return curEquip;
    }
예제 #8
0
        void OnClickBuy(object ob = null)
        {
            PlayerModel playerModel = ModelManager.Get("PlayerModel") as PlayerModel;
            int         emptyIndex  = playerModel.GetEmptyPreIndex();

            if (emptyIndex == -1 && !playerModel.CanRoleUpLevel(roleId, 1, 2))
            {
                WndTips.ShowTips("您的备战区已满,不能再获得角色");
            }
            else
            {
                (ModelManager.Get("RoleShopModel") as RoleShopModel).OnBuyRole(index);
            }
        }
예제 #9
0
    //-----------------------------------------------------------------------------------羁绊

    //-----------------------------------------------------------------------------------羁绊

    /// <summary>
    /// 准备队列增加角色,(交换战斗队列与准备队列的角色时不走该接口
    /// </summary>
    /// <param name="role">角色</param>
    /// <param name="idx">角色即将所在准备队列中的索引</param>
    /// <param name="orIdx">角色在战斗队列中的索引</param>
    public bool AddRolePre(RoleBase role)
    {
        //判断准备队列里有多少个角色
        int count = 0;

        for (int i = 0; i < preRoles.Length; i++)
        {
            if (preRoles[i] != null)
            {
                count++;
            }
        }
        //小于最大的角色数量
        if (count < Max_Pre_Role_Count)
        {
            //找个空位置给他
            for (int i = 0; i < preRoles.Length; i++)
            {
                if (preRoles[i] == null)
                {
                    preRoles[i] = role;

                    EventManager.ExecuteEvent(EventType.PreRoleUpdate, i);

                    TryRoleUpLevel(role.GetRoleId(), role.GetLevel());

                    break;
                }
            }
            return(true);
        }
        else    //角色满了
        {
            //先判断是否可以合成
            bool res = TryRoleUpLevel(role.GetRoleId(), role.GetLevel(), 2);
            if (!res)
            {
                WndTips.ShowTips("玩家准备区域拥有的角色达到最大数量");
            }

            return(res);
        }
    }
예제 #10
0
    public void TryUpPeopleLevel()
    {
        //先判等级
        if (peopleLevel >= MaxPeopleLevel)
        {
            WndTips.ShowTips("人口已达最大限度,不可继续升级!");
            return;
        }

        bool can = SetMoney(-4 * peopleLevel);

        if (can)
        {
            UpdateLevel();
        }
        else
        {
            WndTips.ShowTips("余额不足,不可升级人口!");
        }
    }
예제 #11
0
    public void OnBuyRole(int index)
    {
        int id = roles[index];

        int cost = ConfigRoleManager.Instance().allDatas[id].cost;

        int price = cost - zhekou;

        if (playerModel.SetMoney(-price))
        {
            roles[index] = 0; //买了后 id 设置为0

            playerModel.AddRolePre(id);

            EventManager.ExecuteEvent(EventType.ShopDataUpdate);
        }
        else
        {
            WndTips.ShowTips("您的余额不足以购买该角色!");
        }
    }
예제 #12
0
    void OnOverTime()
    {
        WndTips.ShowTips("所有角色伤害提升500%!\n战斗速度提升1.5倍!");
        Time.timeScale = 1.5f;
        AudioManager.instance.BgAudioSource.pitch = 1.5f;

        foreach (RoleBase role in playerRoles)
        {
            if (role != null)
            {
                role.attackValueParam += overTimeBL;
                role.skillParam       += overTimeBL;
            }
        }
        foreach (RoleBase role in aiRoles)
        {
            if (role != null)
            {
                role.attackValueParam += overTimeBL;
                role.skillParam       += overTimeBL;
            }
        }
    }
예제 #13
0
    /// <summary>
    /// 交换2个队列中的角色数据
    /// </summary>
    /// <param name="role">具体角色</param>
    /// <param name="fightIndex">即将落户的战斗队列索引</param>
    /// <param name="preIndex">准备队列索引</param>
    public bool ExChangeRolesBetPreAndFight(int fightIndex, int preIndex)
    {
        RoleBase fightRole = fightRoles[fightIndex];

        if (fightRole == null)
        {
            int count = GetFightRoleCount();
            if (count >= peopleLevel)
            {
                WndTips.ShowTips("战斗队列角色已达上限,不可再上阵角色!");

                return(false);
            }
        }
        RoleBase preRole = preRoles[preIndex];

        RemoveFightRole(fightIndex, EnumType.RoleUpdateType.FightToPre); //减少属性并更新羁绊
        SetPreRole(fightRole, preIndex);                                 //pre 来自fight

        AddFightRole(preRole, fightIndex);                               //判断该角色是否需要获取羁绊属性,更新羁绊

        return(true);
    }
예제 #14
0
    public override void OnFirstOpen()
    {
        base.OnFirstOpen();

        talentBtn = GetGameObject("talentBtn");

        gameLevelModel = ModelManager.Get("GameLevelModel") as GameLevelModel;

        equipNumber      = GetText("belowUI/bag/number");
        fightCountText   = GetText("fightCount");
        preCountText     = GetText("preCount");
        moneyText        = GetText("belowUI/money/value");
        gameLevelText    = GetText("gameLevel");
        levelUpMoneyText = GetText("belowUI/levelUp/levelUpMoney");

        sellGo   = GetGameObject("sell");
        sellRect = GetRectTransform("sell");
        sellGo.SetActive(false);
        sellPriceText = GetText("sell/price");
        playerHpText  = GetText("playerHp");

        wndTips     = ViewManager.Get <WndTips>("WndTips");
        playerModel = ModelManager.Get("PlayerModel") as PlayerModel;

        int preCount   = PlayerModel.Max_Pre_Role_Count;
        int fightCount = FightManager.Max_Fight_List_Number;

        talentListRect = GetRectTransform("talentList");
        talentContent  = GetRectTransform("talentList/content");
        selfRect       = go.GetComponent <RectTransform>();

        talentItem = GetGameObject("talentItem");
        talentItem.SetActive(false);
        fightList = GetRectTransform("fightList/list");
        preList   = GetRectTransform("prepareList/list");

        fightPositions = new RectTransform[fightCount];
        for (int i = 0; i < 9; i++)
        {
            fightPositions[i] = fightList.Find(i.ToString()).GetComponent <RectTransform>();
        }

        prePositions = new RectTransform[preCount];
        for (int i = 0; i < preCount; i++)
        {
            prePositions[i] = preList.Find(i.ToString()).GetComponent <RectTransform>();
        }

        fightRoleGos = new GameObject[fightCount];
        for (int i = 0; i < fightCount; i++)
        {
            fightRoleGos[i] = fightPositions[i].Find("Role").gameObject;
        }

        preRoleGos = new GameObject[preCount];
        for (int i = 0; i < preCount; i++)
        {
            preRoleGos[i] = prePositions[i].Find("Role").gameObject;
        }

        fightRoleItems = new RoleItem[fightCount];
        for (int i = 0; i < fightRoleItems.Length; i++)
        {
            fightRoleItems[i] = new RoleItem(fightRoleGos[i], EnumType.RoleListType.Fight, i);
            goItems.Add(fightRoleItems[i].roleGo, fightRoleItems[i]);
        }

        preRoleItems = new RoleItem[preCount];
        for (int i = 0; i < preCount; i++)
        {
            preRoleItems[i] = new RoleItem(preRoleGos[i], EnumType.RoleListType.Pre, i);
            goItems.Add(preRoleItems[i].roleGo, preRoleItems[i]);
        }

        foreach (var v in goItems.Keys)
        {
            var uiDrag = UIDrag.GetUIDrag(v);
            uiDrag.AddBeginDrag(OnBeginDrag);
            uiDrag.AddDrag(OnDrag);
            uiDrag.AddEndDrag(OnEndDrag);
        }
        orTalentListX     = talentListRect.anchoredPosition.x;
        targetTalentListX = orTalentListX - 87;

        helpInfoPlane = GetGameObject("helpInfoPlane");

        AddUIButton("helpInfoBtn", (g) => { helpInfoPlane.SetActive(true); });
        AddUIButton("belowUI/shop", OnClickOpenShop);
        AddUIButton("belowUI/startFight", OnClickStartFight);
        AddUIButton("belowUI/levelUp", OnClickLevelUp);
        AddUIButton("belowUI/bag", OnClickOpenBag);
        AddUIButton("talentBtn", OnClickOpenTalent);
        AddUIButton("belowUI/return", OnClickReturn);
        AddUIButton("helpInfoPlane/helpContent/closeBtn", (g) => { helpInfoPlane.SetActive(false); });
    }
예제 #15
0
    public override void OnFirstOpen()
    {
        wndTips = ViewManager.Get <WndTips>("WndTips");

        aiPos     = new Vector3[3];
        playerPos = new Vector3[3];

        Transform aiPs     = GetTransform("aiPs");
        Transform playerPs = GetTransform("playerPs");

        for (int i = 0; i < 3; i++)
        {
            aiPos[i]     = aiPs.GetChild(i).position;
            playerPos[i] = playerPs.GetChild(i).position;
        }

        base.OnFirstOpen();

        GameObject fightRoleGo = GetGameObject("fightRoleGo");


        fightManager = FightManager.instance;

        int count = FightManager.Max_Fight_List_Number;


        fightPosition = GetRectTransform("fightPosition");

        playerPositions = new RectTransform[count];
        for (int i = 0; i < count; i++)
        {
            playerPositions[i] = fightPosition.Find($"player{i.ToString()}").GetComponent <RectTransform>();
        }
        playerRoleGos = new GameObject[count];
        for (int i = 0; i < count; i++)
        {
            var go = GameObject.Instantiate(fightRoleGo, playerPositions[i]);
            go.transform.localPosition = Vector2.zero;
            playerRoleGos[i]           = go;
        }

        aiPositions = new RectTransform[count];
        for (int i = 0; i < count; i++)
        {
            aiPositions[i] = fightPosition.Find($"ai{i.ToString()}").GetComponent <RectTransform>();
        }

        aiRoleGos = new GameObject[count];
        for (int i = 0; i < count; i++)
        {
            var go = GameObject.Instantiate(fightRoleGo, aiPositions[i]);
            go.transform.localPosition = Vector2.zero;
            aiRoleGos[i] = go;
        }

        foreach (var go in playerRoleGos)
        {
            UIUtil.SetUIOnClick(go, OnClickRole);
        }
        foreach (var go in aiRoleGos)
        {
            UIUtil.SetUIOnClick(go, OnClickRole);
        }
        speedText = GetText("speed/speed");
        AddUIButton("speed", OnClickSpeed);


        GameObject.Destroy(fightRoleGo);
    }