Пример #1
0
    void SendCountEvent()
    {
        BaseEvent e = new BaseEvent();

        e.SetSender(GetComponent <HologramComponent>());
        AWConfig.GetInstance().MainEventContext.Send(e);
        Debug.Log("Event sent " + e.ToString());
    }
Пример #2
0
 protected PlayerCommands GetCmd()
 {
     if (cmd == null)
     {
         cmd = AWConfig.GetInstance()
               .GetLocalPlayer()
               .GetComponent <PlayerCommands> ();
     }
     return(cmd);
 }
Пример #3
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();
     }
 }
Пример #4
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);
    }
Пример #5
0
    /// <summary>
    /// Register the EventListener to the main application EventContext
    /// </summary>
    protected void SubscribeToMainEventContext()
    {
        IEventContext mec = AWConfig.GetInstance().MainEventContext;

        mec.Subscribe(this);
    }