LogError() public static method

public static LogError ( object message ) : void
message object
return void
Ejemplo n.º 1
0
 /// <summary>
 /// 战斗单位移动到targetpos事件,主要判断是不是所有单位都到位了
 /// </summary>
 /// <param name="unit"></param>
 public void OnUnitMoveOver(FightUnit unit)
 {
     if (unit == null)
     {
         EDebug.LogError("FightLogic.OnUnitOver failed, unit is null");
         return;
     }
     unit.State = FightUnitState.Idle;
     //如果所有的单位都移动到指定位置,移除事件,进入下一状态
     if (State == FightState.Prepare)
     {
         bool allUnitIdle = true;
         for (int idx = 0; idx < AllFighters.Count; ++idx)
         {
             FightUnit fightUnit = AllFighters[idx];
             if (fightUnit.IsDead)
             {
                 continue;
             }
             if (fightUnit.State != FightUnitState.Idle)
             {
                 allUnitIdle = false;
                 break;
             }
         }
         //所有单位都到达了指定位置
         if (allUnitIdle)
         {
             ZEventSystem.DeRegister(EventConst.OnUnitMoveOver, this);
             State = FightState.Fight;
         }
     }
 }
Ejemplo n.º 2
0
    //public JObject GetCopyLevelByID(int id) { return getSingleData("Section", id); }

    //public float GetGlobalIntArrayByID(int id)
    //{
    //    JObject global = getSingleData("GlobalValue", id);
    //    return global["value"].ToObject<float>();
    //}
    //public JObject GetSoundArrayByID(int id) {
    //    return getSingleData("Sound", id, false);
    //}
    //public string GetGlobalStringArrayByID(int id) {
    //    JObject global = getSingleData("GlobalStr", id);
    //    return global["desc"].ToString();
    //}
    #endregion


    //#region
    ////TODO:步骤3,根据需要添加特殊处理方法
    //public int GetDropOrderCnt()
    //{
    //    return _dropOrderList.Count;
    //}

    //public Vector2Int GetDropOrder(int idx)
    //{
    //    return _dropOrderList[idx];
    //}

    //#endregion

    private void loadData()
    {
        for (int idx = 0; idx < _allJsonNames.Length; ++idx)
        {
            string fileName = _allJsonNames[idx];
            string jsonStr  = loadFile(fileName);
            JArray jsonArr  = JsonConvert.DeserializeObject(jsonStr) as JArray;
            Dictionary <int, JObject> buffer = new Dictionary <int, JObject>();
            for (int idx2 = 0; idx2 < jsonArr.Count; ++idx2)
            {
                JObject jItem = jsonArr[idx2] as JObject;
                try
                {
                    int id = jItem["ID"].ToObject <int>();
                    if (buffer.ContainsKey(id))
                    {
                        EDebug.LogWarning(string.Format("{0}.json中包含相同的ID:{1}", fileName, id));
                    }
                    else
                    {
                        buffer[id] = jItem;
                    }
                }
                catch (Exception)
                {
                    EDebug.LogError(string.Format("{0}.json缺少名为ID的字段", fileName));
                }
            }

            _allJsonData[fileName] = buffer;
        }
    }
Ejemplo n.º 3
0
 public void Release(T element)
 {
     if (this.m_Stack.Count > 0 && object.ReferenceEquals(this.m_Stack.Peek(), element))
     {
         EDebug.LogError("Internal error. Trying to destroy object that is already released to pool.");
     }
     if (this.m_ActionOnRelease != null)
     {
         this.m_ActionOnRelease(element);
     }
     this.m_Stack.Push(element);
 }
Ejemplo n.º 4
0
    /// <summary>
    /// 退出战场
    /// </summary>
    public void ExitBattleField()
    {
        int lastPos = -1;

        for (int idx = 0; idx < AllFighters.Count; ++idx)
        {
            FightUnit unit = AllFighters[idx];
            if (unit.IsDead)
            {
                continue;
            }
            if (lastPos < 0 || unit.GridPos < lastPos)
            {
                lastPos = unit.GridPos;
            }
        }
        if (lastPos < 0)
        {
            EDebug.LogError("FightLogic.ExitBattleField failed, lastPos < 0");
            return;
        }
        int gridOffset = (lastPos - ((CurRound - 1) * 3 + 1) * PathFinder.AREA_TOTAL) / PathFinder.V_GRID;

        gridOffset = PathFinder.H_GRID * 2 - gridOffset;

        if (gridOffset < 0)
        {
            EDebug.LogErrorFormat("FightLogic.ExitBattleFIeld failed, lastpos:{0} gridOffset:{1}", lastPos, gridOffset);
        }

        for (int idx = 0; idx < AllFighters.Count; ++idx)
        {
            FightUnit unit = AllFighters[idx];
            if (unit.IsDead)
            {
                continue;
            }
            int endPos = unit.GridPos + gridOffset * PathFinder.V_GRID;
            //unit.PathFinderObj.StartFind(endPos);
            unit.GridPos   = endPos;
            unit.TargetPos = PathFinder.Grid2Pos(endPos);
            unit.CurRot.SetLookRotation(Vector3.right);
            unit.State = FightUnitState.Move;
        }
    }
Ejemplo n.º 5
0
    /// <summary>
    /// 选择一个攻击目标
    /// </summary>
    /// <param name="self">自己</param>
    /// <param name="canAttack">是否考虑必须可以攻击到</param>
    /// <returns></returns>
    public FightUnit SelectFightTarget(FightUnit self, bool canAttack)
    {
        if (self == null || self.IsDead)
        {
            EDebug.LogError("FightLogic.SelectFightTarget failed, fightunit is null or dead");
            return(null);
        }
        int   selIdx = -1;
        float dis    = float.MaxValue;

        //先循环一遍看看有没有可以攻击的对象,如果没有,则不考虑是否无敌
        int targetsCanBeAttackCnt = 0;

        for (int idx = 0; idx < AllFighters.Count; ++idx)
        {
            FightUnit unit = AllFighters[idx];
            if (!unit.CanBeAttack(self, false, true, true))
            {
                continue;
            }
            targetsCanBeAttackCnt++;
        }
        for (int idx = 0; idx < AllFighters.Count; ++idx)
        {
            FightUnit unit = AllFighters[idx];
            if (!unit.CanBeAttack(self, 0 == targetsCanBeAttackCnt, !canAttack, false))
            {
                continue;
            }
            //计算距离
            float gridDis = PathFinder.GridDis(self.GridPos, unit.GridPos);
            if (gridDis < dis)
            {
                selIdx = idx;
                dis    = gridDis;
            }
        }
        return((selIdx >= 0) ? AllFighters[selIdx] : null);
    }
Ejemplo n.º 6
0
    public void SetDataAnalyze(List <FightUnit> fighters, List <FightUnit> enemies)
    {
        if (DataAnalyzeViewLeft == null || DataAnalyzeViewRight == null)
        {
            EDebug.LogError("DataAnalyzeNode missing!");
            return;
        }
        int maxHarm = 0;

        for (int idx = 0; idx < fighters.Count; ++idx)
        {
            FightUnit unit = fighters[idx];
            if (unit == null)
            {
                continue;
            }
            if (unit.HarmCount > maxHarm)
            {
                maxHarm = unit.HarmCount;
            }
        }
        for (int idx = 0; idx < enemies.Count; ++idx)
        {
            FightUnit unit = enemies[idx];
            if (unit == null)
            {
                continue;
            }
            if (unit.HarmCount > maxHarm)
            {
                maxHarm = unit.HarmCount;
            }
        }

        float nodeHeight = DataAnalyzeViewLeft.gameObject.GetComponent <RectTransform>().sizeDelta.y;

        for (int idx = 0; idx < fighters.Count; ++idx)
        {
            FightUnit unit = fighters[idx];
            if (unit == null)
            {
                continue;
            }
            GameObject node = GameObject.Instantiate(DataAnalyzeViewLeft.gameObject);
            node.transform.SetParent(Datas_obj.transform, false);
            RectTransform nodeRect = node.GetComponent <RectTransform>();
            nodeRect.anchoredPosition = new Vector2(nodeRect.sizeDelta.x / 2, -(idx + 0.5f) * nodeRect.sizeDelta.y);
            DataAnalyzeView nodeView = node.GetComponent <DataAnalyzeView>();
            nodeView.Init();
            nodeView.SetInfo(JsonMgr.GetSingleton().GetHeroByID(unit.HeroId).headid, unit.Rare, unit.Star, unit.Level, unit.HarmCount, maxHarm);
        }

        for (int idx = 0; idx < enemies.Count; ++idx)
        {
            FightUnit unit = enemies[idx];
            if (unit == null)
            {
                continue;
            }
            GameObject node = GameObject.Instantiate(DataAnalyzeViewRight.gameObject);
            node.transform.SetParent(Datas_obj.transform, false);
            RectTransform nodeRect = node.GetComponent <RectTransform>();
            nodeRect.anchoredPosition = new Vector2(-nodeRect.sizeDelta.x / 2, -(idx + 0.5f) * nodeRect.sizeDelta.y);
            DataAnalyzeView nodeView = node.GetComponent <DataAnalyzeView>();
            nodeView.Init();
            int headId = 0;
            if (unit.IsMonster)
            {
                headId = JsonMgr.GetSingleton().GetMonsterByID(unit.HeroId).headid;
            }
            else
            {
                headId = JsonMgr.GetSingleton().GetHeroByID(unit.HeroId).headid;
            }

            nodeView.SetInfo(headId, unit.Rare, unit.Star, unit.Level, unit.HarmCount, maxHarm);
        }
        RectTransform datasRect = Datas_obj.GetComponent <RectTransform>();

        datasRect.sizeDelta = new Vector2(datasRect.sizeDelta.x, Mathf.Max(fighters.Count, enemies.Count) * nodeHeight);
    }
Ejemplo n.º 7
0
    /// <summary>
    /// 有战斗单位死亡
    /// </summary>
    public void OnUnitDie(FightUnit unit)
    {
        if (unit == null)
        {
            EDebug.LogError("FightLogic.OnUnitDie, unit is null");
            return;
        }

        bool isEnemyDie = unit.IsEnemy;

        List <FightUnit> unitList   = isEnemyDie ? EnemyFighters[CurRound - 1] : Fighters;
        bool             allUnitDie = true;

        for (int idx = 0; idx < unitList.Count; ++idx)
        {
            if (!unitList[idx].IsDead)
            {
                allUnitDie = false;
                break;
            }
        }
        if (allUnitDie)
        {
            for (int idx = 0; idx < AllFighters.Count; ++idx)
            {
                FightUnit fightUnit = AllFighters[idx];
                if (fightUnit.IsSummon)
                {
                    ZEventSystem.Dispatch(EventConst.ForceDestroyView, fightUnit);
                }
                fightUnit.SystemProtect = true;
            }
            if (isEnemyDie)
            {
                //敌人死光了
                for (int idx = 0; idx < AllFighters.Count; ++idx)
                {
                    FightUnit u = AllFighters[idx];
                    if (u.IsDead)
                    {
                        continue;
                    }
                }
                if (CurRound < TotalRound)
                {
                    State = FightState.Continue;
                }
                else
                {
                    //战斗胜利
                    _terminate(true);
                }
            }
            else
            {
                //自己死光了
                _terminate(false);
            }
        }

        //宝箱掉落
        if (Treasures > 0)
        {
            if (isEnemyDie)
            {
                if (allUnitDie && CurRound >= TotalRound)
                {
                    this.DropMgrObj.CreateTreasure(unit.CurPos, Treasures);
                    Treasures = 0;
                }
                else
                {
                    if (Random.Range(0, 1.0f) < this.DropMgrObj.TreasureRate)
                    {
                        this.DropMgrObj.CreateTreasure(unit.CurPos, 1);
                        --Treasures;
                    }
                }
            }
        }
    }
Ejemplo n.º 8
0
    /// <summary>
    /// 开始一场战斗
    /// </summary>
    /// <param name="isPvp">比赛性质,pve还是pvp</param>
    /// <param name="treasures">宝箱数量</param>
    public void CreateFight(bool isPvp, int treasures = 0)
    {
        this.State = FightState.Init;
        if (this.Fighters == null)
        {
            EDebug.LogError("FightLogic.CreateFight failed, fighters is null");
            return;
        }
        if (this.EnemyFighters == null)
        {
            EDebug.LogError("FightLogic.CreateFight failed, fighters is null");
            return;
        }
        if (this.Fighters.Count == 0)
        {
            EDebug.LogError("FightLogic.CreateFight failed, fighters is empty");
            return;
        }
        if (this.EnemyFighters.Count == 0)
        {
            EDebug.LogError("FightLogic.CreateFight failed, enemyFighters is empty");
            return;
        }

        this.TotalRound = this.EnemyFighters.Count;
        this.CurRound   = 0;
        this.IsPvp      = isPvp;
        this.Treasures  = treasures;
        this.DropMgrObj = new DropMgr();
        aStarFinder     = new AStarFinder(PathFinder.V_GRID, (this.TotalRound * 3 + 1) * PathFinder.H_GRID);

        List <FightUnit> allUnit = new List <FightUnit>();

        for (int idx = 0; idx < Fighters.Count; ++idx)
        {
            allUnit.Add(Fighters[idx]);
        }
        for (int idx = 0; idx < EnemyFighters.Count; ++idx)
        {
            for (int idx2 = 0; idx2 < EnemyFighters[idx].Count; ++idx2)
            {
                allUnit.Add(EnemyFighters[idx][idx2]);
            }
        }

        for (int idx = 0; idx < allUnit.Count; ++idx)
        {
            allUnit[idx].UID = ++UID;
        }
        ZEventSystem.Dispatch(EventConst.OnCreateFight, allUnit);

        //Test~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        for (int idx = 0; idx < Fighters.Count; ++idx)
        {
            FightUnit unit = Fighters[idx];
            _createFightUnitView(unit);
        }

        MapMgr.Instance.CreateFightMap(1, TotalRound);
        CamMgrObj = GameObject.Find("Main Camera").GetComponent <CamMgr>();

        //EndTest~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        //注册事件
        ZEventSystem.Register(EventConst.OnFightUnitDie, this, "OnUnitDie");
        ZEventSystem.Register(EventConst.OnFightStateChange, this, "OnFightStateChange");
        ZEventSystem.Register(EventConst.OnRequestUnitPause, this, "OnRequestUnitPause");
        ZEventSystem.Register(EventConst.OnFightMaskOver, this, "OnFightMaskOver");
        ZEventSystem.Register(EventConst.OnGamePause, this, "OnGamePause");

        //CamMgrObj.StartDissolve();
        CamMgrObj.PlayStartEffect();
        NextRound();
        ProcessCtrl.Instance.AddUpdate(this);
    }
Ejemplo n.º 9
0
    public void BuildHeroEvent(int heroId)
    {
        if (showID == heroId)
        {
            return;
        }
        if (Herotf != null)
        {
            Destroy(Herotf.gameObject);
        }
        Vector3 v3 = billboard.GetCamPos();

        v3.y           += -1.45f;
        v3.z           += 10f;
        billboard.Layer = LayerMask.NameToLayer("Hero");
        HeroData data = HeroMgr.GetSingleton().GetHeroData(heroId);

        GameObject heroGo = ResourceMgr.Instance.LoadResource(data.JsonData.resid) as GameObject;

        if (heroGo == null)
        {
            return;
        }
        heroGo = Instantiate(heroGo);
        Herotf = heroGo.transform;
        Herotf.localPosition = v3;
        int horseid = data.JsonData.horseid;

        if (horseid != 0)
        {
            GameObject horseGo = ResourceMgr.Instance.LoadResource(horseid) as GameObject;
            if (horseGo == null)
            {
                EDebug.LogError("加载马匹资源失败 -- " + horseid);
                return;
            }
            horseGo = Instantiate(horseGo, heroGo.transform, false);
            horseGo.transform.localPosition = Vector3.zero;
            horseGo.transform.localScale    = Vector3.one;
        }
        HeroShow hs = JsonMgr.GetSingleton().GetHeroShowByID(heroId);
        Vector3  vc = billboard.Cam.transform.eulerAngles;

        vc.x = hs.RotX;
        Quaternion qc = new Quaternion
        {
            eulerAngles = vc
        };

        billboard.Cam.transform.rotation = qc;
        Vector3 vh = heroGo.transform.localEulerAngles;

        vh.y = hs.RotY + +180f;
        Quaternion qh = new Quaternion
        {
            eulerAngles = vh
        };

        heroGo.transform.rotation = qh;
        billboard.Fov             = hs.Fov;
        showID = heroId;
        heroGo.SetLayer("Hero");
        player = heroGo.AddComponent <AnimatorPlayer>();
        player.RandomPlay(true);
    }