Пример #1
0
        /// <summary>Raised after a mod message is received over the network.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void Multiplayer_ModMessageReceived(object sender, ModMessageReceivedEventArgs e)
        {
            if (e.FromModID != this.Helper.Multiplayer.ModID)
            {
                return;
            }

            // Upon receiving a door state requests as the host with the current state of the doors.
            if (e.Type == nameof(DoorStateRequest) && Context.IsMainPlayer)
            {
                DoorStateRequest request = e.ReadAs <DoorStateRequest>();
                this.Helper.Multiplayer.SendMessage(new DoorStateReply(request.LocationName, this.manager.GetDoorStatesInLocation(request.LocationName)), nameof(DoorStateReply), new[] { this.Helper.Multiplayer.ModID }, new[] { e.FromPlayerID });
            }

            // Upon receiving a door state reply as a farmhand, update the state of the doors.
            if (e.Type == nameof(DoorStateReply) && !Context.IsMainPlayer)
            {
                DoorStateReply reply = e.ReadAs <DoorStateReply>();
                this.manager.SetDoorStates(reply.LocationName, reply.DoorStates);
            }

            // Upon receiving a door toggle, update the door if the location is loaded.
            if (e.Type == nameof(DoorToggle))
            {
                DoorToggle toggle = e.ReadAs <DoorToggle>();
                if (Context.IsMainPlayer || toggle.LocationName == Utils.GetLocationName(Game1.currentLocation))
                {
                    this.manager.ToggleDoor(toggle.LocationName, toggle.Position, toggle.StateBeforeToggle);
                }
            }
        }
Пример #2
0
    public void TogglePathway(DoorToggle dt)
    {
        Block b = edited_room.template.GetBlock(dt.Position().position);

        b.SetPathway(dt.Position().pathway, dt.is_doorway);
        foreach (Tile t in dt.GetComponentsInChildren <Tile>(true))
        {
            if (t.gameObject.activeSelf)
            {
                RemoveTile(t.position, false);
                t.gameObject.SetActive(false);
            }
            else
            {
                t.gameObject.SetActive(true);
            }
        }
        foreach (Tile t in dt.GetComponentsInChildren <Tile>())
        {
            if (t.gameObject.activeSelf)
            {
                AddTile(t, t.position);
            }
        }
    }
Пример #3
0
 /// <summary>
 /// Overriden method for when scripts starts
 /// </summary>
 protected override void Start()
 {
     base.Start();
     wires = GetComponentsInChildren <CutAction>();
     foreach (CutAction wire in wires)
     {
         wire.ResetWire();
     }
     door = GetComponentInChildren <DoorToggle>();
     indicator.GetComponent <MeshRenderer>().material = new Material(indicator.GetComponent <MeshRenderer>().material.shader);
     audioSource = GetComponent <AudioSource>();
 }
    // Use this for initialization
    void Start()
    {
        m_ai                     = GameObject.FindGameObjectWithTag("AI");
        m_aiPowerScript          = m_ai.GetComponent <AIPower>();
        m_doorLockPower          = m_aiPowerScript.doorLockedPower;
        m_doorControllerScript   = m_ai.GetComponent <DoorController>();
        m_doorsLength            = m_doorControllerScript.m_specificDoorScripts.Length;
        m_doorLockedToggleArray  = new Toggle[m_doorsLength];
        m_doorPoweredToggleArray = new Toggle[m_doorsLength];
        m_countingDown           = new float[m_doorsLength];
        m_isCounting             = new bool[m_doorsLength];
        m_lockedOutAction        = new bool[m_doorsLength];
        m_shutOutTime            = shutOutTime;

        for (int i = 0; i < m_doorsLength; i++)
        {
            GameObject doorToggleClone = Instantiate(doorToggles, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
            //new Text[3] cloneText = doorToggleClone.GetComponentsInChildren<Text>();
            Text[] cloneText = new Text[3];
            cloneText = doorToggleClone.GetComponentsInChildren <Text>();
            for (int j = 0; j < 3; j++)
            {
                cloneText[j].font = textFont;
            }
            //.font = textFont;
            doorToggleClone.transform.SetParent(gameObject.transform);

            DoorToggle doorToggleScript = doorToggleClone.GetComponent <DoorToggle>();

            m_doorToggleArray           = doorToggleClone.GetComponentsInChildren <Toggle>();
            m_doorLockedToggleArray[i]  = m_doorToggleArray[0];
            m_doorPoweredToggleArray[i] = m_doorToggleArray[1];

            doorToggleScript.doorID = i;
            doorToggleScript.ChangeName();

            m_countingDown[i] = m_shutOutTime;

            m_lockedOutAction[i] = false;
        }
    }
Пример #5
0
 // Start is called before the first frame update
 void Start()
 {
     DoorParentScriptReference = transform.parent.transform.parent.GetComponent <DoorToggle>();
 }