Esempio n. 1
0
        private void Awake()
        {
            rb      = GetComponent <Rigidbody>();
            ownable = GetComponent <OwnableObject>();

            rb.sleepThreshold = 0.01f;
        }
Esempio n. 2
0
 public override void setOwner(NetworkInstanceId newOwner)
 {
     if (isServer)
     {
         if (newOwner == owner)
         {
             return;
         }
         Player oldOwner = this.getPlayerOwner();
         if (oldOwner != null)
         {
             oldOwner.owned.removeId(this.netId);
         }
         Player p = getLocalInstance(newOwner).GetComponent <Player> ();
         p.owned.addId(this.netId);
         owner = newOwner;
         foreach (NetId netId in lotItems)
         {
             NetworkInstanceId id  = netId.id;
             OwnableObject     b   = getLocalInstance(id).GetComponent <OwnableObject> ();
             Player            tmp = b.getPlayerOwner();
             if (tmp != null)
             {
                 b.getPlayerOwner().owned.removeId(id);
             }
             b.setOwner(newOwner);
             b.notForSale = true;
         }
     }
 }
Esempio n. 3
0
    private void OnSceneGUI()
    {
        OwnableObject ownable = (OwnableObject)target;

        if (ownable.Owner == null)
        {
            return;
        }

        Type type = typeof(OwnableObject);

        int ownershipChangedFrame = (int)type.GetField("ownershipFrameChanged", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(ownable);
        int authorityChangedFrame = (int)type.GetField("authorityFrameChanged", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(ownable);

        Handles.BeginGUI();
        Vector2 pos2D = HandleUtility.WorldToGUIPoint(ownable.transform.position);

        GUILayout.BeginArea(new Rect(pos2D, Vector2.one * 150));
        GUI.backgroundColor = new Color(1, 1, 1, 0.5f);
        GUILayout.Box($"Owner: { ownable.Owner.Value}\n" +
                      $"Authority: {ownable.Authority.Value}\n" +
                      $"Owner frame: {ownershipChangedFrame}\n" +
                      $"Authority frame: {authorityChangedFrame}\n" +
                      $"Sleeping: {ownable.GetComponent<Rigidbody>().IsSleeping()}");
        GUILayout.EndArea();
        Handles.EndGUI();
    }
Esempio n. 4
0
    public void removeObject(NetworkInstanceId id)
    {
        lotItems.removeId(id);
        OwnableObject tmp = getLocalInstance(id).GetComponent <OwnableObject> ();

        lotAttractiveness -= tmp.getAttractEffect();
        lotObjects.Remove(tmp);
    }
Esempio n. 5
0
    public override void OnInspectorGUI()
    {
        OwnableObject ownable = (OwnableObject)serializedObject.targetObject;

        // If the Owner property is null, then the object has not been initialized.
        if (ownable.Owner == null)
        {
            return;
        }
    }
Esempio n. 6
0
    /// <summary>
    /// tallies up the rent value of all buildings on the lot
    /// </summary>
    /// <returns>The total rent.</returns>
    public int calcPrice()
    {
        int price = 600;               // base cost of the lot

        foreach (NetId id in lotItems) // add cost from each building
        {
            OwnableObject b = getLocalInstance(id.id).GetComponent <OwnableObject> ();
            price += b.appraise();
        }
        return(price);
    }
Esempio n. 7
0
    public void addObject(NetworkInstanceId id)
    {
        lotItems.addId(id);
        OwnableObject tmp = getLocalInstance(id).GetComponent <OwnableObject> ();

        if (lotObjects == null)
        {
            lotSetup();
        }
        lotObjects.Add(tmp);
        if (!validOwner())
        {
            cost = calcPrice();
        }
        lotAttractiveness += tmp.getAttractEffect();
    }
Esempio n. 8
0
    public List <OwnableObject> getObjects()
    {
        List <OwnableObject> buildings;

        if (isServer)
        {
            buildings = lotObjects;
        }
        else
        {
            buildings = new List <OwnableObject> ();
            foreach (NetId n in lotItems)
            {
                OwnableObject tmp = getLocalInstance(n.id).GetComponent <OwnableObject> ();
                buildings.Add(tmp);
            }
        }
        return(buildings);
    }
Esempio n. 9
0
 private void Start()
 {
     ownable = GetComponent <OwnableObject>();
     ownable.Owner.OnChanged     += OnOwnableChanged;
     ownable.Authority.OnChanged += OnOwnableChanged;
 }
Esempio n. 10
0
 private void Awake()
 {
     rb      = GetComponent <Rigidbody>();
     ownable = GetComponent <OwnableObject>();
 }
Esempio n. 11
0
 public void RemoveItem(OwnableObject n)
 {
     regionalObjects.removeId(n.netId);
 }
Esempio n. 12
0
 public void AddItem(OwnableObject n)
 {
     regionalObjects.addId(n.netId);
 }