Exemplo n.º 1
0
    /// <summary>
    /// 创建一个怪物角色的U3D对象,将其加入到RoleManager下
    /// </summary>
    /// <param name="roleInfo"></param>
    /// <param name="pos"></param>
    /// <returns></returns>
    public Enemy CreateEnemy(RoleInfo roleInfo, int pos)
    {
        GameObject enemyObj = CreateRoleObject(roleInfo);
        RoleBase   roleBase = RoleFactory.CreateRole(roleInfo);

        Enemy enemy = enemyObj.GetComponent <Enemy>();

        switch (roleInfo.style)
        {
        case CommonDefine.RoleStyle.Normal:
            enemy.skin.sharedMaterial.SetColor("_Color", Color.white);
            break;

        case CommonDefine.RoleStyle.Red:
            enemy.skin.sharedMaterial.SetColor("_Color", Color.red);
            break;

        case CommonDefine.RoleStyle.Blue:
            enemy.skin.sharedMaterial.SetColor("_Color", Color.blue);
            break;
        }

        if (enemyObj != null)
        {
            enemyObj.GetComponent <Enemy>().Init(roleBase);
            enemyObj.transform.parent     = m_hideRoleArea.transform;
            enemyObj.transform.localScale = Vector3.one;
        }

        AddEnemyInBattle(roleBase, pos);
        return(enemyObj.GetComponent <Enemy>());
    }
Exemplo n.º 2
0
    /// <summary>
    /// 将指定的Role放入战斗列表
    /// </summary>
    /// <param name="roleId"></param>
    /// <param name="player"></param>
    public void AddRoleInBattle(RoleInfo roleInfo, int pos)// RoleBase player)
    {
        if (!m_roleInBattleDic.ContainsKey(roleInfo.id))
        {
            m_roleInBattleDic.Add(roleInfo.id, RoleFactory.CreateRole(roleInfo));
            m_roleInBattleDic[roleInfo.id].m_playerPosition = pos;
        }

        RefreshSelectHero();
    }
Exemplo n.º 3
0
    //玩家获得新角色,准备队列中增加新角色, 购买时 以id传参
    public void AddRolePre(int roleId, int level = 1)
    {
        RoleBase role = RoleFactory.CreateRole(roleId, level);

        AddRolePre(role);
    }
Exemplo n.º 4
0
    //判断该角色是否可以升级,穿入该角色的id与等级,角色升级是直接生成一个新角色,还不是在原角色基础上修改
    bool TryRoleUpLevel(int roleId, int level, int composeCount = 3)
    {
        if (level == 3)
        {
            return(false);
        }

        //找到可以升级的 n 个角色
        //2个队列中的索引
        List <int> preRs   = new List <int>(composeCount);
        List <int> fightRs = new List <int>(composeCount);

        for (int i = 0; i < preRoles.Length; i++)
        {
            var role = preRoles[i];
            if (role == null)
            {
                continue;
            }

            if (role.GetRoleId() == roleId && role.GetLevel() == level)
            {
                preRs.Add(i);
            }
        }
        for (int i = 0; i < fightRoles.Length; i++)
        {
            var role = fightRoles[i];
            if (role == null)
            {
                continue;
            }

            if (role.GetRoleId() == roleId && role.GetLevel() == level)
            {
                fightRs.Add(i);
            }
        }
        //移出角色
        if (preRs.Count + fightRs.Count == composeCount)
        {
            for (int i = 0; i < preRs.Count; i++)
            {
                preRoles[preRs[i]].RemoveAllEquip();
                RemoveRolePre(preRs[i], preRoles[preRs[i]].GetRoleId());
            }
            for (int i = 0; i < fightRs.Count; i++)
            {
                RemoveFightRole(fightRs[i], EnumType.RoleUpdateType.RemoveFight);
            }
        }
        else
        {
            return(false);
        }
        //获得升级后的角色,放到战斗队列中找到的第一个该角色
        //此处新生成的角色是因升级而成,所以因该派发 升级 事件,进行升级的特殊响应
        int index;

        if (fightRs.Count > 0)
        {
            index = fightRs[0];
            RoleBase role = RoleFactory.CreateRole(roleId, level + 1);

            AddFightRole(role, index);
        }
        else
        {
            AddRolePre(roleId, level + 1);
        }

        AudioManager.instance.PlayEffect(ConstConfig.RoleUpLevel);

        return(true);
    }
Exemplo n.º 5
0
        public void Factory_CreateRoleTypeAdministrator_ReturnsAdministratorRole()
        {
            var role = _roleFactory.CreateRole("Administrator");

            Assert.IsInstanceOf <AdministratorRole>(role);
        }