Esempio n. 1
0
    /// <summary>
    /// Setups the scene from the editor and popups warning if some
    /// configuration problem is found.
    /// </summary>
    /// <param name="controlCenter">Control center.</param>
    static void SetupAWConfig(GameObject controlCenter)
    {
        AWConfig config = controlCenter.GetComponent <AWConfig>();

        config.netSystem = netSystem;
        config.arSystem  = arSystem;
        if (netSystem == NetSystem.HLAPI)
        {
            AWNetworkManager netManager = controlCenter.GetComponent <AWNetworkManager>();
            if (netManager == null)
            {
                Debug.LogWarning("Networking system setted to HLAPI, " +
                                 "but no AWNetworkManager found on AWControlCenter");
            }
        }
        if (arSystem == ARSystem.Vuforia)
        {
            GameObject arCameraGO = GameObject.Find("ARCamera");
            if (arCameraGO == null || !arCameraGO.activeInHierarchy)
            {
                Debug.LogWarning("ARCamera for Vuforia not found or inactive, " +
                                 " remember to configure it properly.");
            }
            else
            {
                VuforiaBehaviour vb = arCameraGO.GetComponent <VuforiaBehaviour>();
                if (vb.AppLicenseKey.Length < 2)
                {
                    Debug.LogWarning("Is the VuforiaBehaviour License Key setted correctly?");
                }
            }
        }
    }
Esempio n. 2
0
    void SendCountEvent()
    {
        BaseEvent e = new BaseEvent();

        e.SetSender(GetComponent <HologramComponent>());
        AWConfig.GetInstance().MainEventContext.Send(e);
        Debug.Log("Event sent " + e.ToString());
    }
Esempio n. 3
0
 protected PlayerCommands GetCmd()
 {
     if (cmd == null)
     {
         cmd = AWConfig.GetInstance()
               .GetLocalPlayer()
               .GetComponent <PlayerCommands> ();
     }
     return(cmd);
 }
Esempio n. 4
0
 //IMPORTANT - Inject the reference of the local player game object
 //Can only be done here
 public override void OnStartLocalPlayer()
 {
     base.OnStartLocalPlayer();
     AWConfig.GetInstance().SetLocalPlayer(this.gameObject);
     Debug.Log("Saved instance of the local player");
     //chain to netSync components
     HLAPINetworkSync[] hnss = Object.FindObjectsOfType <HLAPINetworkSync> ();
     foreach (HLAPINetworkSync hns in hnss)
     {
         hns.OnStartLocalPlayer();
     }
 }
Esempio n. 5
0
    /// <summary>
    /// Disables this component for client instance of the application.
    /// Useful when using networking system where the server is based
    /// on Unity Engine like HLAPI.
    /// </summary>
    /// <param name="disableGameObject">If set to <c>true</c> disable game object.</param>
    protected void DisableOnClient(bool disableGameObject)
    {
        bool isServer = AWConfig.IsServer();

        if (!isServer && disableOnClient)
        {
            if (disableGameObject)
            {
                gameObject.SetActive(false);
            }
            enabled = false;
        }
    }
Esempio n. 6
0
    void CmdSpawnPrefab(string name, Vector3 position, Quaternion rotation)
    {
        //get the prefab from the resource folder
        Debug.Log("searching for: " + "prefabs/" + name);
        GameObject prefab        = Resources.Load("prefabs/" + name, typeof(GameObject)) as GameObject;
        GameObject placingObject = null;

        if (prefab != null)
        {
            placingObject = Instantiate(prefab, position, rotation) as GameObject;
            placingObject.transform.parent = AWConfig.GetInstance().GetWorldTransform();
        }
        if (placingObject == null)
        {
            Log("Can't spawn something that I don't have - " + name);
            return;
        }
        RpcLog("Spawning: " + placingObject.name);
        NetworkServer.Spawn(placingObject);
    }
Esempio n. 7
0
    /// <summary>
    /// Register the EventListener to the main application EventContext
    /// </summary>
    protected void SubscribeToMainEventContext()
    {
        IEventContext mec = AWConfig.GetInstance().MainEventContext;

        mec.Subscribe(this);
    }