/// <summary> ///是否属于某个阵营关系 /// </summary> /// <param name="factiontype">想去判断的阵营关系</param> /// <param name="selfCampType">阵营类型1(读表定义的阵营)</param> /// <param name="targetCampType">阵营类型2(读表定义的阵营)</param> /// <returns></returns> public bool IsBelongToThisFactionType(FactionType factiontype, BaseEntity entity1, BaseEntity entity2) { //左边:FactionType,右边 :CampRelation //自己= 自己,友方(包含自己) = 友方+中立,敌方 = 敌方,All = 友方+中立+敌方 //自己 if (factiontype == FactionType.Self) { return(entity1.UId() == entity2.UId()); } CfgEternityProxy cfgEternityProxy = GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy; CampRelation campRelation = cfgEternityProxy.GetRelation(entity1.GetCampID(), entity2.GetCampID()); //友方 if (factiontype == FactionType.Friendly) { return(campRelation == CampRelation.Friend || campRelation == CampRelation.Neutrality); } //敌方 if (factiontype == FactionType.Enemy) { return(campRelation == CampRelation.Enemy); } //所有 if (factiontype == FactionType.All) { return(campRelation != CampRelation.Undefined); } return(false); }
public bool CanAttackToTarget(SpacecraftEntity attacker, SpacecraftEntity target) { if (attacker == null || target == null) { return(false); } //优先判断是否可被攻击 if (!target.GetCanBeAttack()) { return(false); } CfgEternityProxy cfgEternityProxy = GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy; //直接调用获取阵营关系的函数,岂不简单些? CampRelation relation = cfgEternityProxy.GetRelation(attacker.GetCampID(), target.GetCampID()); return(relation == CampRelation.Enemy); //int attCamp = attacker.GetCampID(); //int tarCamp = target.GetCampID(); //CampVO_MergeObject? campVO = cfgCampProxy.GetCampRelationVO(attCamp, tarCamp); //if (campVO == null) //{ // Debug.LogErrorFormat("阵营信息不存在. Camp1: {0}, Camp2: {1}", attCamp, tarCamp); // return false; //} //else //{ // int prestage = attacker.GetPrestige(tarCamp); // // 通过声望值判断是否可攻击 // return prestage > campVO.Value.PrestigeEnemyMin && prestage < campVO.Value.PrestigeEnemyMax; //} }