Beispiel #1
0
        public void PullReset(NetworkInstanceId netID)
        {
            if (netID == null)
            {
                netID = NetworkInstanceId.Invalid;
            }

            transform.hasChanged = false;
            if (netID == NetworkInstanceId.Invalid)
            {
                if (pullingObject != null)
                {
                    pullRegister.editModeControl.Snap();
                    pullRegister.UpdateTile(pullingObject.transform.position);
                    EditModeControl eM = pullingObject.GetComponent <EditModeControl>();
                    eM.Snap();
                }
                pullRegister  = null;
                pullingObject = null;
            }
            else
            {
                pullingObject = ClientScene.FindLocalObject(netID);
                ObjectActions oA = pullingObject.GetComponent <ObjectActions>();
                pullPos = pullingObject.transform.position;
                if (oA != null)
                {
                    oA.pulledBy = gameObject;
                }
                pullRegister = pullingObject.GetComponent <RegisterTile>();
            }
        }
Beispiel #2
0
 void Start()
 {
     UpdateTile();
     editModeControl      = GetComponent <EditModeControl>();
     currentTileTypeIndex = TileType.List.IndexOf(TileType);
     tileTypeIndex        = currentTileTypeIndex;
 }
Beispiel #3
0
 void Start()
 {
     snapControl = GetComponent <EditModeControl>();
     if (PhotonNetwork.connectedAndReady)
     {
         //Has been instantiated at runtime and you received instantiate of this object from photon on room join
         StartSync();
     }
 }
Beispiel #4
0
    void UpdateState(bool _aliveState)
    {
        OnVisibilityChange(_aliveState);

        MonoBehaviour[] scripts   = GetComponentsInChildren <MonoBehaviour>(true);
        Collider2D[]    colliders = GetComponentsInChildren <Collider2D>();
        Renderer[]      renderers = GetComponentsInChildren <Renderer>(true);
        for (int i = 0; i < scripts.Length; i++)
        {
            if (scripts[i].GetType().Name != networkId && scripts[i].GetType().Name != networkT &&
                scripts[i].GetType().Name != objectBehaviour &&
                scripts[i].GetType().Name != regTile && scripts[i].GetType().Name
                != inputController && scripts[i].GetType().Name
                != playerSync)
            {
                scripts[i].enabled = _aliveState;
            }
        }

        for (int i = 0; i < colliders.Length; i++)
        {
            colliders[i].enabled = _aliveState;
        }

        for (int i = 0; i < renderers.Length; i++)
        {
            renderers[i].enabled = _aliveState;
        }

        if (registerTile != null)
        {
            if (_aliveState)
            {
                EditModeControl eC = gameObject.GetComponent <EditModeControl>();
                if (eC != null)
                {
                    eC.Snap();
                }

                registerTile.UpdateTile(transform.position);
            }
            else
            {
                registerTile.RemoveTile();
            }
        }
    }
Beispiel #5
0
        //When dropping items etc, remove them from the player equipment pool and place in scene
        public void DropGameObject(GameObject gObj, Vector3 pos)
        {
            NetworkIdentity id = gObj.GetComponent <NetworkIdentity>();

            if (currentObjects.ContainsKey(id))
            {
                currentObjects[id].gameObject.transform.parent   = null;
                currentObjects[id].gameObject.transform.position = pos;
                EditModeControl e = gObj.GetComponent <EditModeControl>();
                e.Snap();
                currentObjects.Remove(id);
            }
            else
            {
                Debug.Log("item: " + gObj.name + "was not found in Player Equipment pool");
            }
        }
Beispiel #6
0
        public void PullReset(NetworkInstanceId netID)
        {
            pullObjectID = netID;
            if (netID == null)
            {
                netID = NetworkInstanceId.Invalid;
            }

            transform.hasChanged = false;
            if (netID == NetworkInstanceId.Invalid)
            {
                if (pullingObject != null)
                {
                    pullRegister.UpdateTile(pullingObject.transform.position);
                    EditModeControl eM = pullingObject.GetComponent <EditModeControl>();
                    if (eM != null)
                    {
                        //This is for objects with editmodecontrol on them
                        eM.Snap();
                    }
                    else
                    {
                        //Could be a another player
                        PlayerSync otherPlayerSync = pullingObject.GetComponent <PlayerSync>();
                        if (otherPlayerSync != null)
                        {
                            CmdSetPositionFromReset(gameObject, otherPlayerSync.gameObject, pullingObject.transform.position);
                        }
                    }
                }
                pullRegister  = null;
                pullingObject = null;
            }
            else
            {
                pullingObject = ClientScene.FindLocalObject(netID);
                PushPull oA = pullingObject.GetComponent <PushPull>();
                pullPos = pullingObject.transform.position;
                if (oA != null)
                {
                    oA.pulledBy = gameObject;
                }
                pullRegister = pullingObject.GetComponent <RegisterTile>();
            }
        }
    private void OnSceneGUI()
    {
        EditModeControl editModeControl = target as EditModeControl;

        if (currentPosition != editModeControl.transform.position)
        {
            currentPosition = editModeControl.transform.position;
            editModeControl.Snap();
            // TODO remove
            //            var registerTile = editModeControl.GetComponent<RegisterTile>();
            //            if(registerTile) {
            //                registerTile.UpdateTile();
            //
            //                var connectTrigger = editModeControl.GetComponent<ConnectTrigger>();
            //                if(connectTrigger) {
            //                    connectTrigger.UpdatePosition();
            //                }
            //            }
        }
    }
Beispiel #8
0
        /// <summary>
        ///     clientside simulation of placement
        /// </summary>
        public bool PlaceItem(Vector3 pos)
        {
            GameObject item = Clear();

            if (!item)
            {
                return(false);
            }
            //            InputTrigger.Touch(item);
            item.transform.position = pos;
            item.transform.parent   = null;
            EditModeControl e = item.GetComponent <EditModeControl>();

            e.Snap();
            ItemAttributes itemAttributes = item.GetComponent <ItemAttributes>();

            Debug.LogFormat("Placing item {0}/{1} from {2} to {3}", item.name,
                            itemAttributes ? itemAttributes.itemName : "(no iAttr)", eventName, pos);
            return(true);
        }
Beispiel #9
0
 void Awake()
 {
     targetPos       = transform.position;
     registerTile    = GetComponent <RegisterTile>();
     editModeControl = GetComponent <EditModeControl>();
 }