using UnityEngine;
using System.Collections;
public class Sun : MonoBehaviour {
public StateMachine<Sun> m_pStateMachine;
public bool track=true;
public Texture[] coverSunFrames;
public Texture[] winFrames;
public Texture[] trackFrames;
public Texture[] normalFrames;
public GameObject childObject;
public bool isRendering=false;
private float lastTime=0;
private float curtTime=0;
//private bool lastRendering=false;
//public bool inNothingState=false;
private int index;
// Use this for initialization
void Start () {
tag="Sun";
m_pStateMachine = new StateMachine<Sun>(this);
m_pStateMachine.SetCurrentState(Sun_NothingState .Instance());
track=true;
GameObject theCloud = GameObject.FindWithTag("CoverCloudPS");
iTween.ScaleTo(theCloud.gameObject,new Vector3(theCloud.gameObject.transform.localScale.x*2.5f,theCloud.gameObject.transform.localScale.y,theCloud.gameObject.transform.localScale.z*4.0f),0.1f);
theCloud.renderer.enabled = false;
setTrack(false);
}
void OnWillRenderObject()
{
curtTime=Time.time;
}
// Update is called once per frame
void Update () {
isRendering=curtTime!=lastTime?true:false;
lastTime=curtTime;
/*
if(isRendering==true&&lastRendering==false&&TempValue.sunTrackDis>=0){
//Debug.Log(Time.time+" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~show sun");
TempValue.sunTrackDis=TempValue.dis;
lastRendering=true;
}
if(isRendering==false&&lastRendering==true&&TempValue.sunTrackDis>=0){
TempValue.sunTrackDis=TempValue.dis;
lastRendering=false;
}
*/
Vector3 tempVec3=transform.position;
//tempVec3.y=Camera.main.transform.position.y+4.5f;
//tempVec3.z=Camera.main.transform.position.z;
tempVec3.y=Camera.main.transform.position.y;
tempVec3+=new Vector3(0,4.5f,0);
transform.position=tempVec3;
m_pStateMachine.SMUpdate();
/*
if(track==false) return;
Vector3 tempVec3=transform.position;
//tempVec3.y=Camera.main.transform.position.y+4.5f;
//tempVec3.z=Camera.main.transform.position.z;
tempVec3.y=Camera.main.transform.position.y;
tempVec3+=new Vector3(0,4.5f,0);
transform.position=tempVec3;
GameObject carGameObject= GameObject.FindWithTag("Player");
float dis=carGameObject.transform.localPosition.z-transform.position.z;//+originalPosition.localPosition.z;
if(dis<32){
Debug.Log("ok");
}
else{
tempVec3=rigidbody.velocity;
tempVec3.z=MyValues.topSpeedX+6;//carGameObject.rigidbody.velocity.z+0.2f;
rigidbody.velocity=tempVec3;
}
*/
}
public void setWinState(bool b){
track=b;
if(track==true){
m_pStateMachine.ChangeState(Sun_Win_State.Instance());
}
else {
m_pStateMachine.ChangeState(Sun_Covered_State.Instance());
//rigidbody.velocity=Vector3.zero;
}
}
public void setTrack(bool b){
track=b;
if(track==true){
TempValue.sunTrackDis=TempValue.dis;
m_pStateMachine.ChangeState(Sun_TrackState .Instance());
}
else{
m_pStateMachine.ChangeState(Sun_NothingState .Instance());
//rigidbody.velocity=Vector3.zero;
}
}
public void state_set_CloudCovered(bool isSet){
if(isSet==true){
m_pStateMachine.ChangeState(Sun_Covered_State.Instance());
}
else{
//m_pStateMachine.ChangeState(Sun_TrackState.Instance());
if(track==true){
m_pStateMachine.ChangeState(Sun_TrackState.Instance());
}else{
m_pStateMachine.ChangeState(Sun_NothingState.Instance());
}
}
}
public void loopframe () {
int nowIndex=(int)(Time.time *6) % coverSunFrames.Length;
if(index!=nowIndex){
index = nowIndex;
renderer.material.mainTexture = coverSunFrames[index];
}
}
public void loopframe (Texture[] frames) {
int nowIndex=(int)(Time.time *6) % frames.Length;
if(index!=nowIndex){
index = nowIndex;
renderer.material.mainTexture = frames[index];
}
}
public StateMachine<Sun> GetFSM ()
{
return m_pStateMachine;
}
}
public class Sun_TrackState :State<Sun>//Track状态
{
//private float enterTime;
private static Sun_TrackState instance;
public static Sun_TrackState Instance ()
{
if (instance == null)
instance = new Sun_TrackState ();
return instance;
}
public override void Enter (Sun Entity)
{
//base.Enter (Entity);
//Debug.Log(Time.time+ " enter track");
Vector3 tempVec3=Entity.transform.position;
//tempVec3.z=Camera.main.transform.position.z-14.0f;
tempVec3.z=Camera.main.transform.position.z-150.0f;
Entity.transform.position=tempVec3;
}
public override void Execute (Sun Entity)
{
//base.Execute (Entity);
Entity.loopframe(Entity.normalFrames);
Vector3 tempVec3=Entity.transform.position;
GameObject carGameObject= GameObject.FindWithTag("Player");
float dis=carGameObject.transform.localPosition.z-Entity.transform.position.z;//+originalPosition.localPosition.z;
if(dis<32){
Entity.GetFSM ().ChangeState(Sun_RacingState .Instance());
return;
}
else{
tempVec3=Entity.rigidbody.velocity;
tempVec3.z=MyValues.topSpeedX+5+TempValue.dis / MyValues.changeSceneDis;//carGameObject.rigidbody.velocity.z+0.2f;
tempVec3.z+=MyValues.addSpeedX;
if (tempVec3.z >= 40)
{
// 追击状态下boss最高速度为40m/s
tempVec3.z = 40;
}
Entity.rigidbody.velocity=tempVec3;
}
}
public override void Exit (Sun Entity)
{
//base.Exit (Entity);
}
}
public class Sun_RacingState :State<Sun>//Racing状态
{
private float enterTime;
private Vector3 tempVec3;
private bool audioPlay = false;
private static Sun_RacingState instance;
public static Sun_RacingState Instance ()
{
if (instance == null)
instance = new Sun_RacingState ();
return instance;
}
public override void Enter (Sun Entity)
{
//base.Enter (Entity);
//Debug.Log(Time.time+ " enter racing");
audioPlay = false;
tempVec3=Entity.transform.position;
tempVec3=Entity.rigidbody.velocity;
tempVec3.z=MyValues.topSpeedX+6;//carGameObject.rigidbody.velocity.z+0.2f;
tempVec3.z+=MyValues.addSpeedX;
Entity.rigidbody.velocity=tempVec3;
enterTime=Time.time;
}
public override void Execute (Sun Entity)
{
//base.Execute (Entity);
GameObject carGameObject= GameObject.FindWithTag("Player");
float dis=carGameObject.transform.localPosition.z-Entity.transform.position.z;//+originalPosition.localPosition.z;
if(dis>32){
Entity.GetFSM ().ChangeState(Sun_TrackState .Instance());
return;
}
if(Time.time-enterTime>16){
Entity.GetFSM ().ChangeState(Sun_RacingState .Instance());
return;
}
else if(Time.time-enterTime > 3){
//Debug.Log(Time.time+ " speedDown");
audioPlay = false;
Entity.loopframe(Entity.normalFrames);
tempVec3.z=MyValues.topSpeedX;
tempVec3.z+=MyValues.addSpeedX;
Entity.rigidbody.velocity=tempVec3;
}
else{
if(audioPlay == false&&Entity.isRendering==true){
audioPlay = true;
Audio audio= GameObject.FindWithTag("Audio").GetComponent<Audio>();
audio.PlayOneShot((int)sound_type.sun_pursue);
}
Entity.loopframe(Entity.trackFrames);
//Debug.Log(Time.time+ " speedUp");
tempVec3.z=MyValues.topSpeedX+3;
tempVec3.z+=MyValues.addSpeedX;
Entity.rigidbody.velocity=tempVec3;
}
}
public override void Exit (Sun Entity)
{
//base.Exit (Entity);
}
}
public class Sun_NothingState :State<Sun>//Nothing状态
{
//private float enterTime;
private static Sun_NothingState instance;
public static Sun_NothingState Instance ()
{
if (instance == null)
instance = new Sun_NothingState ();
return instance;
}
public override void Enter (Sun Entity)
{
//base.Enter (Entity);
//TempValue.sunTrackDis=-1;
//Entity.inNothingState=true;
//Vector3 tempVec3=Entity.transform.position;
//tempVec3.z=-150.0f;
//Entity.transform.position=tempVec3;
}
public override void Execute (Sun Entity)
{
//base.Execute (Entity);
Vector3 tempVec3=Entity.transform.position;
tempVec3=Entity.rigidbody.velocity;
tempVec3.z=0;//carGameObject.rigidbody.velocity.z+0.2f;
Entity.rigidbody.velocity=tempVec3;
}
public override void Exit (Sun Entity)
{
//base.Exit (Entity);
//TempValue.sunTrackDis=TempValue.dis;
}
}
public class Sun_Covered_State :State<Sun>//the sun is covered by cloud迥カ諤
{
private float enterTime;
private static Sun_Covered_State instance;
public static Sun_Covered_State Instance ()
{
if (instance == null)
instance = new Sun_Covered_State ();
return instance;
}
public override void Enter (Sun Entity)
{
//base.Enter (Entity);
Audio audio= GameObject.FindWithTag("Audio").GetComponent<Audio>();
audio.PlayOneShot((int)sound_type.sun_surprise);
TempValue.bossCovered = true;
TempValue.blockSunTimes++;
//Vector3 tempVec3=Entity.transform.position;
enterTime = Time.time;
Vector3 tempVec3=Entity.rigidbody.velocity;
tempVec3.z=MyValues.topSpeedX*0.0f;//carGameObject.rigidbody.velocity.z+0.2f;
Entity.rigidbody.velocity=tempVec3;
//GameObject coverCloud = GameObject.FindWithTag("PS_coverCloud");
//coverCloud.renderer.enabled = true;
Entity.childObject.gameObject.renderer.enabled =false;
Entity.childObject.transform.GetChild(0).collider.enabled=false;
Entity.childObject.gameObject.transform.GetComponentInChildren<Collider>().enabled = false;
Entity.childObject.gameObject.transform.GetChild(0).gameObject.layer = 31;//nothing collider layer
}
public override void Execute (Sun Entity)
{
//base.Execute (Entity);
Entity.loopframe();
if(Time.time-enterTime>10){
//Entity.GetFSM ().ChangeState(Sun_TrackState .Instance());
//return;
}
}
public override void Exit (Sun Entity)
{
TempValue.bossCovered = false;
//GameObject CoverCloud = GameObject.FindWithTag("CoverCloud");
//GameObject.Destroy(CoverCloud.gameObject);
Entity.childObject.gameObject.renderer.enabled =true;
Entity.childObject.transform.GetChild(0).collider.enabled=true;
Entity.childObject.gameObject.transform.GetComponentInChildren<Collider>().enabled = true;
Entity.childObject.gameObject.transform.GetChild(0).gameObject.layer = 19;//sun collider layer
//base.Exit (Entity);
}
}
public class Sun_Win_State :State<Sun>//the sun win
{
private float enterTime;
private Vector3 tempVec3;
private static Sun_Win_State instance;
public static Sun_Win_State Instance ()
{
if (instance == null)
instance = new Sun_Win_State ();
return instance;
}
public override void Enter (Sun Entity)
{
Audio audio= GameObject.FindWithTag("Audio").GetComponent<Audio>();
//audio.PlayOneShot((int)sound_type.sun_laugh);
audio.PlayLoop((int)sound_type.sun_laugh);
enterTime = Time.time;
tempVec3 = Entity.rigidbody.velocity;
tempVec3.z = 30.0f;
Entity.rigidbody.velocity=tempVec3;
/*
//base.Enter (Entity);
//Vector3 tempVec3=Entity.transform.position;
enterTime = Time.time;
Vector3 tempVec3=Entity.rigidbody.velocity;
tempVec3.z=MyValues.topSpeedX*0.0f;//carGameObject.rigidbody.velocity.z+0.2f;
Entity.rigidbody.velocity=tempVec3;
//GameObject coverCloud = GameObject.FindWithTag("PS_coverCloud");
//coverCloud.renderer.enabled = true;
Entity.childObject.gameObject.renderer.enabled =false;
Entity.childObject.transform.GetChild(0).collider.enabled=false;
*/
}
public override void Execute (Sun Entity)
{
//base.Execute (Entity);
Entity.loopframe(Entity.winFrames);
if(Time.time-enterTime>2.0f){
//Entity.GetFSM ().ChangeState(Sun_TrackState .Instance());
//return;
TempValue.gameover = true;
}
}
public override void Exit (Sun Entity)
{
Audio audio= GameObject.FindWithTag("Audio").GetComponent<Audio>();
//audio.PlayOneShot((int)sound_type.sun_laugh);
audio.StopLoop((int)sound_type.sun_laugh);
//Entity.onlyOnce = true;
/*
//GameObject CoverCloud = GameObject.FindWithTag("CoverCloud");
//GameObject.Destroy(CoverCloud.gameObject);
Entity.childObject.gameObject.renderer.enabled =true;
Entity.childObject.transform.GetChild(0).collider.enabled=true;
//base.Exit (Entity);
*/
}
}
using System.Collections;
public class Sun : MonoBehaviour {
public StateMachine<Sun> m_pStateMachine;
public bool track=true;
public Texture[] coverSunFrames;
public Texture[] winFrames;
public Texture[] trackFrames;
public Texture[] normalFrames;
public GameObject childObject;
public bool isRendering=false;
private float lastTime=0;
private float curtTime=0;
//private bool lastRendering=false;
//public bool inNothingState=false;
private int index;
// Use this for initialization
void Start () {
tag="Sun";
m_pStateMachine = new StateMachine<Sun>(this);
m_pStateMachine.SetCurrentState(Sun_NothingState .Instance());
track=true;
GameObject theCloud = GameObject.FindWithTag("CoverCloudPS");
iTween.ScaleTo(theCloud.gameObject,new Vector3(theCloud.gameObject.transform.localScale.x*2.5f,theCloud.gameObject.transform.localScale.y,theCloud.gameObject.transform.localScale.z*4.0f),0.1f);
theCloud.renderer.enabled = false;
setTrack(false);
}
void OnWillRenderObject()
{
curtTime=Time.time;
}
// Update is called once per frame
void Update () {
isRendering=curtTime!=lastTime?true:false;
lastTime=curtTime;
/*
if(isRendering==true&&lastRendering==false&&TempValue.sunTrackDis>=0){
//Debug.Log(Time.time+" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~show sun");
TempValue.sunTrackDis=TempValue.dis;
lastRendering=true;
}
if(isRendering==false&&lastRendering==true&&TempValue.sunTrackDis>=0){
TempValue.sunTrackDis=TempValue.dis;
lastRendering=false;
}
*/
Vector3 tempVec3=transform.position;
//tempVec3.y=Camera.main.transform.position.y+4.5f;
//tempVec3.z=Camera.main.transform.position.z;
tempVec3.y=Camera.main.transform.position.y;
tempVec3+=new Vector3(0,4.5f,0);
transform.position=tempVec3;
m_pStateMachine.SMUpdate();
/*
if(track==false) return;
Vector3 tempVec3=transform.position;
//tempVec3.y=Camera.main.transform.position.y+4.5f;
//tempVec3.z=Camera.main.transform.position.z;
tempVec3.y=Camera.main.transform.position.y;
tempVec3+=new Vector3(0,4.5f,0);
transform.position=tempVec3;
GameObject carGameObject= GameObject.FindWithTag("Player");
float dis=carGameObject.transform.localPosition.z-transform.position.z;//+originalPosition.localPosition.z;
if(dis<32){
Debug.Log("ok");
}
else{
tempVec3=rigidbody.velocity;
tempVec3.z=MyValues.topSpeedX+6;//carGameObject.rigidbody.velocity.z+0.2f;
rigidbody.velocity=tempVec3;
}
*/
}
public void setWinState(bool b){
track=b;
if(track==true){
m_pStateMachine.ChangeState(Sun_Win_State.Instance());
}
else {
m_pStateMachine.ChangeState(Sun_Covered_State.Instance());
//rigidbody.velocity=Vector3.zero;
}
}
public void setTrack(bool b){
track=b;
if(track==true){
TempValue.sunTrackDis=TempValue.dis;
m_pStateMachine.ChangeState(Sun_TrackState .Instance());
}
else{
m_pStateMachine.ChangeState(Sun_NothingState .Instance());
//rigidbody.velocity=Vector3.zero;
}
}
public void state_set_CloudCovered(bool isSet){
if(isSet==true){
m_pStateMachine.ChangeState(Sun_Covered_State.Instance());
}
else{
//m_pStateMachine.ChangeState(Sun_TrackState.Instance());
if(track==true){
m_pStateMachine.ChangeState(Sun_TrackState.Instance());
}else{
m_pStateMachine.ChangeState(Sun_NothingState.Instance());
}
}
}
public void loopframe () {
int nowIndex=(int)(Time.time *6) % coverSunFrames.Length;
if(index!=nowIndex){
index = nowIndex;
renderer.material.mainTexture = coverSunFrames[index];
}
}
public void loopframe (Texture[] frames) {
int nowIndex=(int)(Time.time *6) % frames.Length;
if(index!=nowIndex){
index = nowIndex;
renderer.material.mainTexture = frames[index];
}
}
public StateMachine<Sun> GetFSM ()
{
return m_pStateMachine;
}
}
public class Sun_TrackState :State<Sun>//Track状态
{
//private float enterTime;
private static Sun_TrackState instance;
public static Sun_TrackState Instance ()
{
if (instance == null)
instance = new Sun_TrackState ();
return instance;
}
public override void Enter (Sun Entity)
{
//base.Enter (Entity);
//Debug.Log(Time.time+ " enter track");
Vector3 tempVec3=Entity.transform.position;
//tempVec3.z=Camera.main.transform.position.z-14.0f;
tempVec3.z=Camera.main.transform.position.z-150.0f;
Entity.transform.position=tempVec3;
}
public override void Execute (Sun Entity)
{
//base.Execute (Entity);
Entity.loopframe(Entity.normalFrames);
Vector3 tempVec3=Entity.transform.position;
GameObject carGameObject= GameObject.FindWithTag("Player");
float dis=carGameObject.transform.localPosition.z-Entity.transform.position.z;//+originalPosition.localPosition.z;
if(dis<32){
Entity.GetFSM ().ChangeState(Sun_RacingState .Instance());
return;
}
else{
tempVec3=Entity.rigidbody.velocity;
tempVec3.z=MyValues.topSpeedX+5+TempValue.dis / MyValues.changeSceneDis;//carGameObject.rigidbody.velocity.z+0.2f;
tempVec3.z+=MyValues.addSpeedX;
if (tempVec3.z >= 40)
{
// 追击状态下boss最高速度为40m/s
tempVec3.z = 40;
}
Entity.rigidbody.velocity=tempVec3;
}
}
public override void Exit (Sun Entity)
{
//base.Exit (Entity);
}
}
public class Sun_RacingState :State<Sun>//Racing状态
{
private float enterTime;
private Vector3 tempVec3;
private bool audioPlay = false;
private static Sun_RacingState instance;
public static Sun_RacingState Instance ()
{
if (instance == null)
instance = new Sun_RacingState ();
return instance;
}
public override void Enter (Sun Entity)
{
//base.Enter (Entity);
//Debug.Log(Time.time+ " enter racing");
audioPlay = false;
tempVec3=Entity.transform.position;
tempVec3=Entity.rigidbody.velocity;
tempVec3.z=MyValues.topSpeedX+6;//carGameObject.rigidbody.velocity.z+0.2f;
tempVec3.z+=MyValues.addSpeedX;
Entity.rigidbody.velocity=tempVec3;
enterTime=Time.time;
}
public override void Execute (Sun Entity)
{
//base.Execute (Entity);
GameObject carGameObject= GameObject.FindWithTag("Player");
float dis=carGameObject.transform.localPosition.z-Entity.transform.position.z;//+originalPosition.localPosition.z;
if(dis>32){
Entity.GetFSM ().ChangeState(Sun_TrackState .Instance());
return;
}
if(Time.time-enterTime>16){
Entity.GetFSM ().ChangeState(Sun_RacingState .Instance());
return;
}
else if(Time.time-enterTime > 3){
//Debug.Log(Time.time+ " speedDown");
audioPlay = false;
Entity.loopframe(Entity.normalFrames);
tempVec3.z=MyValues.topSpeedX;
tempVec3.z+=MyValues.addSpeedX;
Entity.rigidbody.velocity=tempVec3;
}
else{
if(audioPlay == false&&Entity.isRendering==true){
audioPlay = true;
Audio audio= GameObject.FindWithTag("Audio").GetComponent<Audio>();
audio.PlayOneShot((int)sound_type.sun_pursue);
}
Entity.loopframe(Entity.trackFrames);
//Debug.Log(Time.time+ " speedUp");
tempVec3.z=MyValues.topSpeedX+3;
tempVec3.z+=MyValues.addSpeedX;
Entity.rigidbody.velocity=tempVec3;
}
}
public override void Exit (Sun Entity)
{
//base.Exit (Entity);
}
}
public class Sun_NothingState :State<Sun>//Nothing状态
{
//private float enterTime;
private static Sun_NothingState instance;
public static Sun_NothingState Instance ()
{
if (instance == null)
instance = new Sun_NothingState ();
return instance;
}
public override void Enter (Sun Entity)
{
//base.Enter (Entity);
//TempValue.sunTrackDis=-1;
//Entity.inNothingState=true;
//Vector3 tempVec3=Entity.transform.position;
//tempVec3.z=-150.0f;
//Entity.transform.position=tempVec3;
}
public override void Execute (Sun Entity)
{
//base.Execute (Entity);
Vector3 tempVec3=Entity.transform.position;
tempVec3=Entity.rigidbody.velocity;
tempVec3.z=0;//carGameObject.rigidbody.velocity.z+0.2f;
Entity.rigidbody.velocity=tempVec3;
}
public override void Exit (Sun Entity)
{
//base.Exit (Entity);
//TempValue.sunTrackDis=TempValue.dis;
}
}
public class Sun_Covered_State :State<Sun>//the sun is covered by cloud迥カ諤
{
private float enterTime;
private static Sun_Covered_State instance;
public static Sun_Covered_State Instance ()
{
if (instance == null)
instance = new Sun_Covered_State ();
return instance;
}
public override void Enter (Sun Entity)
{
//base.Enter (Entity);
Audio audio= GameObject.FindWithTag("Audio").GetComponent<Audio>();
audio.PlayOneShot((int)sound_type.sun_surprise);
TempValue.bossCovered = true;
TempValue.blockSunTimes++;
//Vector3 tempVec3=Entity.transform.position;
enterTime = Time.time;
Vector3 tempVec3=Entity.rigidbody.velocity;
tempVec3.z=MyValues.topSpeedX*0.0f;//carGameObject.rigidbody.velocity.z+0.2f;
Entity.rigidbody.velocity=tempVec3;
//GameObject coverCloud = GameObject.FindWithTag("PS_coverCloud");
//coverCloud.renderer.enabled = true;
Entity.childObject.gameObject.renderer.enabled =false;
Entity.childObject.transform.GetChild(0).collider.enabled=false;
Entity.childObject.gameObject.transform.GetComponentInChildren<Collider>().enabled = false;
Entity.childObject.gameObject.transform.GetChild(0).gameObject.layer = 31;//nothing collider layer
}
public override void Execute (Sun Entity)
{
//base.Execute (Entity);
Entity.loopframe();
if(Time.time-enterTime>10){
//Entity.GetFSM ().ChangeState(Sun_TrackState .Instance());
//return;
}
}
public override void Exit (Sun Entity)
{
TempValue.bossCovered = false;
//GameObject CoverCloud = GameObject.FindWithTag("CoverCloud");
//GameObject.Destroy(CoverCloud.gameObject);
Entity.childObject.gameObject.renderer.enabled =true;
Entity.childObject.transform.GetChild(0).collider.enabled=true;
Entity.childObject.gameObject.transform.GetComponentInChildren<Collider>().enabled = true;
Entity.childObject.gameObject.transform.GetChild(0).gameObject.layer = 19;//sun collider layer
//base.Exit (Entity);
}
}
public class Sun_Win_State :State<Sun>//the sun win
{
private float enterTime;
private Vector3 tempVec3;
private static Sun_Win_State instance;
public static Sun_Win_State Instance ()
{
if (instance == null)
instance = new Sun_Win_State ();
return instance;
}
public override void Enter (Sun Entity)
{
Audio audio= GameObject.FindWithTag("Audio").GetComponent<Audio>();
//audio.PlayOneShot((int)sound_type.sun_laugh);
audio.PlayLoop((int)sound_type.sun_laugh);
enterTime = Time.time;
tempVec3 = Entity.rigidbody.velocity;
tempVec3.z = 30.0f;
Entity.rigidbody.velocity=tempVec3;
/*
//base.Enter (Entity);
//Vector3 tempVec3=Entity.transform.position;
enterTime = Time.time;
Vector3 tempVec3=Entity.rigidbody.velocity;
tempVec3.z=MyValues.topSpeedX*0.0f;//carGameObject.rigidbody.velocity.z+0.2f;
Entity.rigidbody.velocity=tempVec3;
//GameObject coverCloud = GameObject.FindWithTag("PS_coverCloud");
//coverCloud.renderer.enabled = true;
Entity.childObject.gameObject.renderer.enabled =false;
Entity.childObject.transform.GetChild(0).collider.enabled=false;
*/
}
public override void Execute (Sun Entity)
{
//base.Execute (Entity);
Entity.loopframe(Entity.winFrames);
if(Time.time-enterTime>2.0f){
//Entity.GetFSM ().ChangeState(Sun_TrackState .Instance());
//return;
TempValue.gameover = true;
}
}
public override void Exit (Sun Entity)
{
Audio audio= GameObject.FindWithTag("Audio").GetComponent<Audio>();
//audio.PlayOneShot((int)sound_type.sun_laugh);
audio.StopLoop((int)sound_type.sun_laugh);
//Entity.onlyOnce = true;
/*
//GameObject CoverCloud = GameObject.FindWithTag("CoverCloud");
//GameObject.Destroy(CoverCloud.gameObject);
Entity.childObject.gameObject.renderer.enabled =true;
Entity.childObject.transform.GetChild(0).collider.enabled=true;
//base.Exit (Entity);
*/
}
}