mirror of
https://github.com/Mukheem/TwinTurbine.git
synced 2025-05-07 02:00:35 +02:00
Implemented Inheritence
Co-Authored-By: ZeinabBF <145973209+ZeinabBF@users.noreply.github.com>
This commit is contained in:
parent
01e8803348
commit
08d350dd7c
Assets
@ -58,9 +58,7 @@ public class API : MonoBehaviourPunCallbacks, IPunObservable
|
|||||||
private AudioController audioControllerScript;
|
private AudioController audioControllerScript;
|
||||||
public bool turn_WT_on_Y_Axis = false;
|
public bool turn_WT_on_Y_Axis = false;
|
||||||
|
|
||||||
public GameObject windTurbineWithMap;
|
|
||||||
private GameObject windTurbineController;
|
|
||||||
private Windturbine windTurbineControllerScript;
|
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
@ -70,8 +68,7 @@ public class API : MonoBehaviourPunCallbacks, IPunObservable
|
|||||||
photonView = PhotonView.Get(this);
|
photonView = PhotonView.Get(this);
|
||||||
photonView.RPC("RPC_EmergencyButtonClick", RpcTarget.All);
|
photonView.RPC("RPC_EmergencyButtonClick", RpcTarget.All);
|
||||||
|
|
||||||
windTurbineWithMap = GameObject.FindGameObjectWithTag("Wind_Turbine_withMap");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
@ -182,8 +179,6 @@ public void ExtractDataFromJson(string json)
|
|||||||
Debug.Log("Latest WS is - "+latestWS);
|
Debug.Log("Latest WS is - "+latestWS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
windTurbineController = windTurbineWithMap.transform.GetChild(0).gameObject;
|
|
||||||
windTurbineControllerScript = windTurbineController.GetComponent<Windturbine>();
|
|
||||||
photonView = PhotonView.Get(this);
|
photonView = PhotonView.Get(this);
|
||||||
photonView.RPC("RPC_GreenButtonClick", RpcTarget.All,windDirectionInDirectionTerms,LatestT+" C","Kista",latestWS+" m/s",true);
|
photonView.RPC("RPC_GreenButtonClick", RpcTarget.All,windDirectionInDirectionTerms,LatestT+" C","Kista",latestWS+" m/s",true);
|
||||||
}
|
}
|
||||||
@ -201,7 +196,7 @@ public void ExtractDataFromJson(string json)
|
|||||||
|
|
||||||
Debug.Log("Flag value to turn the Y Axis:" + turn_WT_on_Y_Axis);
|
Debug.Log("Flag value to turn the Y Axis:" + turn_WT_on_Y_Axis);
|
||||||
|
|
||||||
windTurbineControllerScript.WT_TurnOnIts_Y_Axis();
|
//windTurbineControllerScript.WT_TurnOnIts_Y_Axis();
|
||||||
}
|
}
|
||||||
[PunRPC]
|
[PunRPC]
|
||||||
public void RPC_VoltageUpdate(String voltageGenerated)
|
public void RPC_VoltageUpdate(String voltageGenerated)
|
||||||
|
@ -3,12 +3,12 @@ using System.Collections;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class Windturbine : MonoBehaviour
|
public class Windturbine : API
|
||||||
{
|
{
|
||||||
float angle;
|
float angle;
|
||||||
public float speed;
|
public float speed;
|
||||||
private API apiScript;
|
//private API apiScript;
|
||||||
private GameObject GUIdataGameObject;
|
//private GameObject GUIdataGameObject;
|
||||||
PhotonView photonView;
|
PhotonView photonView;
|
||||||
|
|
||||||
public float startRotationY = 0f;
|
public float startRotationY = 0f;
|
||||||
@ -21,8 +21,8 @@ public class Windturbine : MonoBehaviour
|
|||||||
{
|
{
|
||||||
angle = Random.Range(0.0f, 120.0f);
|
angle = Random.Range(0.0f, 120.0f);
|
||||||
speed = Random.Range(75.0f, 86.0f);
|
speed = Random.Range(75.0f, 86.0f);
|
||||||
GUIdataGameObject = GameObject.FindGameObjectWithTag("GUIData");
|
//GUIdataGameObject = GameObject.FindGameObjectWithTag("GUIData");
|
||||||
apiScript = GUIdataGameObject.GetComponent<API>();
|
//apiScript = GUIdataGameObject.GetComponent<API>();
|
||||||
|
|
||||||
//THis condition is to detach the map with the Wind turbine after Instantiating. This helps the map stick to the ground when the turbine rotates.
|
//THis condition is to detach the map with the Wind turbine after Instantiating. This helps the map stick to the ground when the turbine rotates.
|
||||||
GameObject.FindGameObjectWithTag("map").transform.SetParent(null); ;
|
GameObject.FindGameObjectWithTag("map").transform.SetParent(null); ;
|
||||||
@ -35,10 +35,10 @@ public class Windturbine : MonoBehaviour
|
|||||||
photonView = PhotonView.Get(this);
|
photonView = PhotonView.Get(this);
|
||||||
photonView.RPC("RPC_WT_Turn", RpcTarget.All);
|
photonView.RPC("RPC_WT_Turn", RpcTarget.All);
|
||||||
|
|
||||||
if(apiScript.turn_WT_on_Y_Axis)
|
if(turn_WT_on_Y_Axis) //From Base class
|
||||||
{
|
{
|
||||||
WT_TurnOnIts_Y_Axis();
|
WT_TurnOnIts_Y_Axis();
|
||||||
apiScript.turn_WT_on_Y_Axis = false;
|
turn_WT_on_Y_Axis = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ public class Windturbine : MonoBehaviour
|
|||||||
{
|
{
|
||||||
//Debug.Log("WIND SPEED FROM API SCRIPT:" + apiScript.latestWS);
|
//Debug.Log("WIND SPEED FROM API SCRIPT:" + apiScript.latestWS);
|
||||||
transform.localEulerAngles = new Vector3(0.0f, 0.0f, angle);
|
transform.localEulerAngles = new Vector3(0.0f, 0.0f, angle);
|
||||||
angle += Time.deltaTime * (apiScript.latestWS * 10); // as the value we are fetching could not turn the blades completely, Multiplying the value we are fetching from API by 10.
|
angle += Time.deltaTime * (latestWS * 10); // as the value we are fetching could not turn the blades completely, Multiplying the value we are fetching from API by 10.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,13 +62,14 @@ public class Windturbine : MonoBehaviour
|
|||||||
public void RPC_WT_TurnOnIts_Y_Axis()
|
public void RPC_WT_TurnOnIts_Y_Axis()
|
||||||
{
|
{
|
||||||
Debug.Log("Rotate On it's Y-Axis");
|
Debug.Log("Rotate On it's Y-Axis");
|
||||||
endRotationY = apiScript.latestWD;
|
endRotationY = latestWD;
|
||||||
StartCoroutine(RotateObject(startRotationY, endRotationY, 3.5f));
|
StartCoroutine(RotateObject(startRotationY, endRotationY, 3.5f));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method to turn the 'Turbine' on its Y axis as per the DIRECTION of wind that is fetched from API
|
// Method to turn the 'Turbine' on its Y axis as per the DIRECTION of wind that is fetched from API
|
||||||
IEnumerator RotateObject(float startAngle, float endAngle, float duration)
|
IEnumerator RotateObject(float startAngle, float endAngle, float duration)
|
||||||
{
|
{
|
||||||
|
Debug.Log("Rotate On it's Y-Axis- COROUTINE");
|
||||||
yield return new WaitForSeconds(2f);
|
yield return new WaitForSeconds(2f);
|
||||||
float timeElapsed = 0f;
|
float timeElapsed = 0f;
|
||||||
Quaternion startRotation = Quaternion.Euler(0, startAngle, 0);
|
Quaternion startRotation = Quaternion.Euler(0, startAngle, 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user