Exemplo n.º 1
0
    /// <summary>
    /// 创建净数据对象
    /// </summary>
    /// <param name="_id"></param>
    /// <returns></returns>
    public static OtherPlayer CreateDummy(OtherPlayerInfo _info)
    {
        GameObject newGO = null;

        if (GameCenter.instance.dummyOpcPrefab != null)
        {
            newGO      = Instantiate(GameCenter.instance.dummyOpcPrefab) as GameObject;
            newGO.name = "Dummy OPC [" + _info.ServerInstanceID + "]";
        }
        else
        {
            newGO = new GameObject("Dummy OPC[" + _info.ServerInstanceID + "]");
        }
        newGO.tag = "Player";
        if (_info.IsActor)
        {
            newGO.SetMaskLayer(LayerMask.NameToLayer("CGPlayer"));
        }
        else
        {
            newGO.SetMaskLayer(LayerMask.NameToLayer("OtherPlayer"));
        }
        OtherPlayer newOPC = newGO.AddComponent <OtherPlayer>();

        newOPC.isDummy_  = true;
        newOPC.moveFSM   = newGO.AddComponent <ActorMoveFSM>();
        newOPC.id        = _info.ServerInstanceID;
        newOPC.actorInfo = _info;

        if (_info.Movespd != 0)
        {
            newOPC.curMoveSpeed = (float)newOPC.actorInfo.StaticSpeed * (float)_info.Movespd / 100f;        //由c002获得
        }
        else
        {
            newOPC.curMoveSpeed = newOPC.actorInfo.StaticSpeed * MOVE_SPEED_BASE;
        }
        //Debug.Log("_info.Movespd:" + _info.Movespd + ",newOPC.actorInfo.StaticSpeed:" + newOPC.actorInfo.StaticSpeed);
        newOPC.CurRealSpeed = newOPC.curMoveSpeed;
        newOPC.RegistMoveEvent(true);
        newOPC.transform.localRotation = new Quaternion(0, _info.RotationY, 0, 0);
        GameCenter.curGameStage.PlaceGameObjectFromServer(newOPC, _info.ServerPos.x, _info.ServerPos.z, (int)newOPC.transform.localEulerAngles.y);
        GameCenter.curGameStage.AddObject(newOPC);
        if (!newOPC.actorInfo.IsActor) //过场动画演员不展示名字
        {
            newOPC.height       = newOPC.actorInfo.NameHeight;
            newOPC.nameHeight   = newOPC.height;
            newOPC.headTextCtrl = newOPC.gameObject.AddComponent <HeadTextCtrl>();
            newOPC.headTextCtrl.SetRelationship(newOPC.GetRelationship());
            newOPC.headTextCtrl.SetRelationColor(newOPC.GetRelationshipColor());
            newOPC.headTextCtrl.SetName("[b]" + (newOPC.actorInfo.Name));
            newOPC.headTextCtrl.SetGuildName(newOPC.actorInfo.GuildName);
            newOPC.headTextCtrl.SetTitleSprite(newOPC.actorInfo.TitleIcon);
            newOPC.InitNameColor();
        }
        return(newOPC);
    }