﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Gaazar;
using System;
using ProtoBuf;

public class NettedTester : NettedBehavior
{
    // Start is called before the first frame update
    [SyncVar]
    public float Syncfloat;
    [SyncVar]
    int SyncInt;
    [SyncVar]
    Vector3 tPosition { get; set; }

    byte[] tpd;

    [RPCMethod]
    public void TestRPCa(int a,float b,string c,NettedBehavior d)
    {

    }
    [RPCMethod]
    void TestRPCd(NettedBehavior d)
    {
    }
    override public void MonoStart()
    {
        TestRPCd(this);
        TestRPCa(0, 1f, "abc", this);

    }

    // Update is called once per frame
    void Update()
    {
        //return;
        if (Input.GetKeyDown(KeyCode.M))
        {
            foreach (var i in this.rpcMethods)
            {
                Debug.Log(i.Name +" "+i.GetParameters().ToString());
            }
        }
        if (Input.GetKeyDown(KeyCode.V))
        {
            foreach (var i in this.syncVars)
            {
                Debug.Log(i.Name + " " + i.MemberType);
            }
        }
        if (Input.GetKeyDown(KeyCode.T))
        {

            Syncfloat = transform.rotation.x;
            tPosition = transform.position;
            ((INetted)this).Send(out tpd);
            //GetComponent<NettedBasic>
            Debug.Log(BitConverter.ToString(tpd));
        }
        /*if (Input.GetKeyDown(KeyCode.A))
        {
            //NettedManager.current.CreatedInstance(nettedID.PackNettedInfo(),"DynamicNettedObject");
            MeshFilter mf = GetComponent<MeshFilter>();
            AssetBundle ab = AssetBundle.LoadFromFile(@"AssetBundles\vehicle\insurgent.veh");
            string[] abn  = ab.GetAllAssetNames();
            foreach (var n in abn)
            {
                Debug.Log(n);
            }
            //ab.LoadAsset("insurgent.veh");
            //GetComponent<MeshFilter>().sharedMesh = msh;
        }*/
    }
}
