Example #1
0
    private void OnSyncNewHero(KProtoBuf buffer)
    {
        S2C_SYNC_NEW_HERO respond = buffer as S2C_SYNC_NEW_HERO;

        if (m_EntityManager.GetEntityById <BaseEntity>(respond.id) != null)
        {
            Debug.LogErrorFormat("已经创建UId为{0}的实体", respond.id);
            return;
        }

        //Debug.LogErrorFormat("====《创建UId为{0}的实体", respond.id);

        CfgEternityProxy cfgEternityProxy = GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy;

        if (cfgEternityProxy.IsSpace())
        {
            m_EntityManager.CreateEntityByRespond <SpacecraftEntity, S2C_SYNC_NEW_HERO>(respond.id, respond.templateID, respond.item_tid, respond.ownerPlayerID, respond);
        }
        else
        {
            m_EntityManager.CreateEntityByRespond <HumanEntity, S2C_SYNC_NEW_HERO>(respond.id, respond.templateID, respond.item_tid, respond.ownerPlayerID, respond);
        }

        Debug.Log("OnSyncNewHero\n" + JsonUtility.ToJson(respond));
    }
Example #2
0
        //public HashSet<uint> debugHeroSet = new HashSet<uint>();
        private void SyncNewHero(KProtoBuf buf)
        {
            S2C_SYNC_NEW_HERO respond = buf as S2C_SYNC_NEW_HERO;

            //log.Error("同步新的英雄 " + respond.id);
            //debugHeroSet.Add(respond.id);
            AddHero(respond);
        }
    public override void OnInitialize(IInitializeAttributeProperty property)
    {
        S2C_SYNC_NEW_HERO respond = property.GetNewHeroRespond();

        property.SetAttribute(AttributeName.kHP, respond.HP);
        property.SetAttribute(AttributeName.kHPMax, respond.MaxHP);
        property.SetAttribute(AttributeName.kShieldValue, respond.shield_value);
        property.SetAttribute(AttributeName.kShieldMax, respond.shield_value_max);
        property.SetAttribute(AttributeName.kPowerValue, respond.EnergyPower);
        property.SetAttribute(AttributeName.kPowerMax, respond.MaxEnergyPower);
        //新屬性目前沒有
        //property.SetAttribute(AttributeName.DefenseShield, respond.defense_shield_value);
        //property.SetAttribute(AttributeName.DefenseShieldTopLimit, respond.defense_shield_value_max);
        //property.SetAttribute(AttributeName.ManaShield, respond.mana_shield_value);
        //property.SetAttribute(AttributeName.ManaShieldTopLimit, respond.mana_shield_value_max);
        //property.SetAttribute(AttributeName.SuperMagnetic, respond.SuperMagnetic);
        //property.SetAttribute(AttributeName.SuperMagneticTopLimit, respond.MaxSuperMagnetic);
        //property.SetAttribute(AttributeName.RadiiOfSight, respond.ViewSight);

        //新屬性目前沒有
        if (property.IsMain())
        {
            Debug.Log("无双值当前: " + respond.current_peerless);
            Debug.Log("无双值最大: " + respond.max_peerless);
        }
        ///property.SetPeerless((uint)respond.current_peerless);
        property.SetAttribute(AttributeName.kConverterValue, respond.current_peerless);
        property.SetAttribute(AttributeName.kConverterMax, respond.max_peerless);

        //for (int i = 0; i < respond.speed_value_list.Length; i++)
        //{
        //    property.SetAttribute((AttributeName)respond.speed_value_list[i].id, respond.speed_value_list[i].value);
        //}
        //for (int i = 0; i < respond.overload_speed_value_list.Length; i++)
        //{
        //    property.SetAttribute((AttributeName)respond.overload_speed_value_list[i].id, respond.overload_speed_value_list[i].value);
        //}
        //for (int i = 0; i < respond.fight_speed_value_list.Length; i++)
        //{
        //    property.SetAttribute((AttributeName)respond.fight_speed_value_list[i].id, respond.fight_speed_value_list[i].value);
        //}
        // property.SetAttribute((AttributeName)respond.human_speed_value_list.id, respond.human_speed_value_list.value);
    }
Example #4
0
    /// <summary>
    /// 保存附近怪物信息
    /// </summary>
    public void SaveNewMonster(S2C_SYNC_NEW_HERO msg)
    {
        if (m_NeedAddUpdate)
        {
            m_NeedAddUpdate = false;
            ServerTimeUtil.Instance.OnTick += Update;
        }

        if (msg == null || msg.ownerPlayerID != 0)
        {
            return;
        }

        Npc       npcData = m_CfgEternityProxy.GetNpcByKey((uint)msg.templateID);
        KHeroType npcType = (KHeroType)npcData.NpcType;

        if (CheckNpcType(npcType))
        {
            if (!m_NearbyMonsterList.Contains(msg.id))
            {
                m_NearbyMonsterList.Add(msg.id);
            }
        }
    }
Example #5
0
 public void InitBaseProperty(S2C_SYNC_NEW_HERO respond)
 {
     m_Name  = respond.szPlayerName;
     m_Level = respond.uLevel;
 }
Example #6
0
 private void OnSaveNewMonster(KProtoBuf buf)
 {
     S2C_SYNC_NEW_HERO msg = buf as S2C_SYNC_NEW_HERO;
     GetMSAIBossProxy().SaveNewMonster(msg);
 }
Example #7
0
        //public static DebugCounter debugCounter =  new DebugCounter();
        public void AddHero(S2C_SYNC_NEW_HERO hero)
        {
            //debugCounter.Restart();
            //debugCounter.AddMark("heroSet");
            KSceneObjectType sot         = KSceneObjectType.sotHero;
            KHeroObjectType  hot         = KHeroObjectType.hotInvalid;
            KDoodadType      dt          = KDoodadType.dddInvalid;
            KHeroSetting     heroSetting = KConfigFileManager.GetInstance().heroSetting.getData(hero.wNpcIDOrJob.ToString());

            log.Assert(heroSetting != null);
            hot = heroSetting.HeroType;
            string Name  = "";
            string Title = "";

            switch (heroSetting.HeroType)
            {
            case KHeroObjectType.hotNpc:
            {
                if (!npcidToSceneidDic.ContainsKey((int)heroSetting.ID))
                {
                    npcidToSceneidDic.Add((int)heroSetting.ID, hero.id);
                }
                else
                {
                    npcidToSceneidDic[(int)heroSetting.ID] = hero.id;
                }
                Name  = heroSetting.Name;
                Title = heroSetting.Title;
            }
            break;

            case KHeroObjectType.hotMonster:
            {
                Name = heroSetting.Name;
            }
            break;

            case KHeroObjectType.hotPlayer:
            {
                Assets.Scripts.Model.Player.Player newPlayerInfo = PlayerManager.GetInstance().GetPlayer(hero.uOwnerID);
                if (newPlayerInfo != null)
                {
                    Name = newPlayerInfo.PlayerName;
                }
                else
                {
                    Name = "not init";
                }
            }
            break;

            default:
            {
                throw new ArgumentException("error heroSetting.HeroType = " + heroSetting.HeroType + " at hero which id = " + hero.id + " uOwnerID =  " + hero.uOwnerID);
            }
            }

            if (hero.uOwnerID == PlayerManager.GetInstance().MajorPlayer.PlayerID)
            {
                PlayerManager.GetInstance().MajorPlayer.hero = hero.id;
                EventDispatcher.GameWorld.Dispath(ControllerCommand.CHANGE_NICKNAME, PlayerManager.GetInstance().MajorPlayer.PlayerName);
            }

            SceneEntity entity = CreateSceneObject(hero.id, sot, hot, dt, MapUtils.GetMetreFromInt(hero.posX, hero.posY), hero.uOwnerID);

            entity.heroSetting = heroSetting;

            if (heroSetting.HeroType == KHeroObjectType.hotMonster && hero.bNewHero != 0)
            {
                entity.property.bNewHero = true;
            }
            entity.Init();
            entity.DispatchEvent(ControllerCommand.SET_SPEED, hero.moveSpeed);
            entity.property.isDeaded    = entity.property.isDeadTemp = (hero.moveState == (byte)KMoveState.mosDeath);
            entity.property.Face        = hero.faceDir;
            entity.property.maxHp       = (int)hero.MaxHP;
            entity.property.maxMp       = (int)hero.MaxMP;
            entity.property.fightHp     = entity.property.hp = (int)hero.HP;
            entity.property.mp          = (int)hero.MP;
            entity.AttackSpeed          = (int)hero.attackSpeed;
            entity.transform.localScale = new Vector3(heroSetting.Scale, heroSetting.Scale, heroSetting.Scale);
            entity.property.characterController.size   = new Vector3(0.7f, 2f, 0.7f);
            entity.property.characterController.center = new Vector3(0, 1, 0);

            if (hot == KHeroObjectType.hotPlayer && hero.uOwnerID == PlayerManager.GetInstance().MajorPlayer.PlayerID)
            {
                SceneLogic.GetInstance().MainHero = entity;
            }

            Vector3 destination = MapUtils.GetMetreFromInt(hero.desX, hero.desZ, hero.desY);

            if (hero.desX == 0 && hero.desZ == 0 && hero.desY == 0)
            {
                destination = MapUtils.GetMetreFromInt(hero.posX, hero.posY);
            }
            entity.TabID = hero.wNpcIDOrJob;
            entity.Job   = KJob.jobNone;
            if (entity.HeroType == KHeroObjectType.hotPlayer)
            {
                entity.Job = (KJob)hero.wNpcIDOrJob;
            }

            entity.DispatchEvent(ControllerCommand.SET_DESTINATION, destination, (int)KForceMoveType.fmtInvalid);
            entity.DispatchEvent(ControllerCommand.CHANGE_NAME, Name);
            entity.DispatchEvent(ControllerCommand.LOAD_RES);
            entity.DispatchEvent(ControllerCommand.LOAD_NAME_LABEL, Name);
            if (Title.Length > 0)
            {
                entity.DispatchEvent(ControllerCommand.CHANGE_TITLE, Title);
            }
            entity.EquipIDs = hero.equipIDs;

            if (entity.property.isDeadTemp)
            {
                entity.property.isDeadTemp = true;
                entity.Action.IsBeDead();
            }
            else if (heroSetting.HeroType == KHeroObjectType.hotMonster && hero.bNewHero != 0)
            {
                entity.ActiveAction = new ActionMousterOut(entity);
            }
        }