private void ThrowSink()
    {
        if (!m_currentSinkController)
        {
            return;
        }

        m_currentSinkController.Throw(m_throwPower);
        m_sinkInHands           = null;
        m_currentSinkController = null;
    }
示例#2
0
 private void Start()
 {
     if (!m_sinkController)
     {
         m_sinkController = GetComponent <SinkController>();
     }
     if (!m_trajectoryRenderer)
     {
         m_trajectoryRenderer = GetComponent <LineRenderer>();
     }
     SinkTrajectory();
 }
    private void SpawnSink()
    {
        m_sinkInHands = Instantiate(m_sinks[Random.Range(0, 3)], m_sinkSpawnPosition);  //Randomize sink spawn
        m_sinkInHands.transform.position = m_sinkSpawnPosition.position;                //Place the sink in the player's hands

        if (!(m_currentSinkController = m_sinkInHands.GetComponent <SinkController>())) //If no sink script component is found, add one
        {
            Debug.LogError("SinkScript not found on " + SinkInHands.name + "\nAdding a simple sink script to fix issue");
            m_currentSinkController = m_sinkInHands.AddComponent <SimpleSink>();
        }

        m_currentSinkController.SinkConstructor(m_sinkSpawnPosition, m_throwPower);  //Call the sink constructor to setup required variables
        //Sinks require a reference to the GameManager so the sink can be tracked, rather than using GameObject.Find I pass in a reference
        m_anim.SetTrigger("prepSink");
    }
 private void ChangeSink()
 {
     if (m_currentBunker.m_storedSink)  //If a sink is already stored here then swap with the sink currently in the players hands
     {
         SinkInHands             = m_currentBunker.SwapSink(SinkInHands);
         m_currentSinkController = SinkInHands.GetComponent <SinkController>();
         SinkInHands.GetComponent <LineRenderer>().enabled = true;
         SinkInHands.transform.parent   = m_sinkSpawnPosition;
         SinkInHands.transform.position = m_sinkSpawnPosition.position;
         SinkInHands.transform.rotation = m_sinkSpawnPosition.rotation;
     }
     else   //If no sink is stored then store the sink currently in the player's hands and spawn a new sink
     //TODO: Possibly remove Bunker script and have the stored sink attached to the player as bunkers are no longer necessary
     {
         m_currentBunker.StoreSink(SinkInHands);   //null check for SinkInHands is done by the Bunker script
         SpawnSink();
     }
 }