Ejemplo n.º 1
0
        private void CreateHero()
        {
            GameObject m_heroNode = GameObject.FindGameObjectWithTag(EGameConstL.TAG_HERO_NODE);

            if (!m_heroModel || !m_heroNode)
            {
                return;
            }

            if (m_allFields.Count == 0)
            {
                EUtilityHelperL.LogWarning("请先创建野外");
                return;
            }

            Hero clone = Instantiate <Hero>(m_heroModel);

            if (clone)
            {
                clone.name = string.Format("Hero_{0}", m_allHeros.Count);
                clone.transform.SetParent(m_heroNode.transform);
                m_allHeros.Add(clone);
                //在城市位置出生
                int     randIdx = Random.Range(0, m_allCities.Count);
                Vector3 pos     = m_allCities[randIdx].transform.position;
                pos.y = 1.51f;
                clone.transform.position = pos;
                clone.gameObject.SetActive(true);
                //初始化
                clone.Init();
                clone.AddExp(Random.Range(0, 50));
            }
        }
Ejemplo n.º 2
0
        //放置一些障碍格子
        private void DisposeGridUnits(int obstacle, int gap)
        {
            obstacle = Mathf.Min(mapWidth * mapHeight, obstacle);

            for (int i = 0; i < obstacle; ++i)
            {
                int          randomIdx = -1;
                GridUnitData target    = null;
                int          tryTimes  = 999;
                while (tryTimes > 0 && target == null)
                {
                    randomIdx = Random.Range(0, normalGrids.Count);
                    target    = normalGrids[randomIdx];
                    //判断距离
                    for (int j = 0; j < obstacleGrids.Count; ++j)
                    {
                        var distance = obstacleGrids[j].Distance(target);
                        if (obstacleGrids[j].Distance(target) < gap)
                        {
                            target = null;
                            break;
                        }
                    }
                    --tryTimes;
                }
                if (target != null)
                {
                    SetGridType(target, GridType.Obstacle);
                    normalGrids.RemoveAt(randomIdx);
                }
                else
                {
                    EUtilityHelperL.LogWarning("Dispose grid unit data warning.");
                }
            }
        }
Ejemplo n.º 3
0
        //计算声望获取倍数
        public float CalculateFameMultiple(HeroData heroData, FieldData fieldData)
        {
            int needLevel = 1;

            if (!fieldDiff.ContainsKey(fieldData.difficulty))
            {
                EUtilityHelperL.LogWarning("错误的野外难度!");
            }
            else
            {
                needLevel = Mathf.FloorToInt(fieldDiff[fieldData.difficulty].key);
            }
            //等级差距
            float lvGap = heroData.level - needLevel;

            for (int i = 0; i < ladderFame.Length; ++i)
            {
                if (lvGap <= ladderFame[i].key)
                {
                    return(ladderFame[i].value);
                }
            }
            return(ladderFame[ladderFame.Length - 1].value);
        }