예제 #1
0
    public void Init(EntitySpawnData data, int rendererLayer)
    {
        Type      = data.objecttype;
        Direction = ((NpcDirection)data.PosDir[2]).ToDirection();

        GID = data.GID;
        AID = data.AID;

        Status.name       = data.name;
        Status.jobId      = data.job;
        Status.sex        = data.sex;
        Status.hair       = (short)data.head;
        Status.walkSpeed  = data.speed;
        Status.hp         = data.HP;
        Status.max_hp     = data.MaxHP;
        Status.char_id    = GID;
        Status.account_id = AID;

        EquipInfo = new EntityEquipInfo {
            Weapon     = (short)data.Weapon,
            Shield     = (short)data.Shield,
            HeadTop    = (short)data.Accessory2,
            HeadBottom = (short)data.Accessory,
            HeadMid    = (short)data.Accessory3,
            Robe       = (short)data.Robe
        };

        gameObject.transform.position = new Vector3(data.PosDir[0], Core.PathFinding.GetCellHeight(data.PosDir[0], data.PosDir[1]), data.PosDir[1]);

        SetupViewer(EquipInfo, rendererLayer);
    }
예제 #2
0
    private void SetupViewer(EntityEquipInfo data, int rendererLayer)
    {
        var body = new GameObject("Body");

        body.layer = rendererLayer;
        body.transform.SetParent(gameObject.transform, false);
        body.transform.localPosition = new Vector3(0.5f, 0.4f, 0.5f);
        body.AddComponent <Billboard>();
        var sortingGroup = body.AddComponent <SortingGroup>();

        sortingGroup.sortingOrder = 2;

        var bodyViewer = body.AddComponent <EntityViewer>();

        bodyViewer.ViewerType    = ViewerType.BODY;
        bodyViewer.Entity        = this;
        bodyViewer.SpriteOffset  = 0.5f;
        bodyViewer.HeadDirection = 0;
        bodyViewer.CurrentMotion = new EntityViewer.MotionRequest {
            Motion = SpriteMotion.Idle
        };

        EntityViewer = bodyViewer;
        ShadowSize   = 1f;
        // Add more options such as sex etc

        // Any other than PC has Head etc
        if (Type != EntityType.PC)
        {
            return;
        }

        InitHead(rendererLayer, bodyViewer);
        MaybeInitLayer(rendererLayer, bodyViewer, data.Weapon, ViewerType.WEAPON);
        MaybeInitLayer(rendererLayer, bodyViewer, data.Shield, ViewerType.SHIELD, 1);
        MaybeInitLayer(rendererLayer, bodyViewer, data.HeadTop, ViewerType.HEAD_TOP);
        MaybeInitLayer(rendererLayer, bodyViewer, data.HeadMid, ViewerType.HEAD_MID);
        MaybeInitLayer(rendererLayer, bodyViewer, data.HeadBottom, ViewerType.HEAD_BOTTOM);
    }
예제 #3
0
    public void Init(CharacterData data, int rendererLayer, bool isFromCharacterSelection = false)
    {
        Type = EntityType.PC;
        GID  = (uint)data.GID;

        Status.walkSpeed  = data.Speed;
        Status.hair       = data.Hair;
        Status.base_exp   = (uint)data.Exp;
        Status.base_level = (uint)data.BaseLevel;
        Status.job_exp    = (uint)data.JobExp;
        Status.job_level  = (uint)data.JobLevel;
        Status.sp         = data.SP;
        Status.max_sp     = data.MaxSP;
        Status.jobId      = data.Job;
        Status.sex        = (byte)data.Sex;
        Status.hp         = data.HP;
        Status.max_hp     = data.MaxHP;
        Status.name       = data.Name;

        EquipInfo = new EntityEquipInfo {
            Weapon     = data.Weapon,
            Shield     = data.Shield,
            HeadTop    = data.Accessory2,
            HeadBottom = data.Accessory,
            HeadMid    = data.Accessory3,
            Robe       = (short)data.Robe
        };

        SetupViewer(EquipInfo, rendererLayer);

        if (isFromCharacterSelection)
        {
            return;
        }

        HookPackets();
    }