public void Start () { // initialize tables EventReader.GetInstance(); ReactionReader.GetInstance(); SequenceReader.GetInstance(); AffectedActionReader.GetInstance(); MoodPointsReader.GetInstance(); ReactionTrackingReader.GetInstance(); TutorialReader.GetInstance(); ResponseManager.Instance.HideIcon(); InstructionsManager.Instance.HideInstruction(); // hold instance m_instance = this; //Load intro rocks m_introRock = Instantiate( Resources.Load( "AnimationTool/INTRO_ROCK" ) ) as GameObject; m_introRock.SetActive( false ); // init anim controller utility GameObject cfController = GameObject.Find("CAREPLAY_NF_Controller") as GameObject; cfController.AddComponent<CarePlayNFController>(); cfController.AddComponent<BiteItemController>(); // init cam controller utility m_cameraController = GameObject.Find ("CAREPLAY_Cam_Controller").GetComponent<CameraRigController>(); // init dragon m_petDragon = GameObject.FindGameObjectWithTag("PetDragon") as GameObject; m_petDragon.gameObject.AddComponent<DragonScript>(); m_petDragon.gameObject.AddComponent<DragonAnimation>(); m_petDragon.gameObject.AddComponent<Dragon>(); m_petDragon.gameObject.AddComponent<JawCruncherStateController>(); m_jcController = m_petDragon.gameObject.GetComponent<JawCruncherStateController>(); // init gestures m_mainCamera = GameObject.FindGameObjectWithTag("MainCamera").gameObject; m_mainCamera.AddComponent<GestureManager>(); m_gestureManager = Camera.mainCamera.gameObject.GetComponent<GestureManager>(); m_gestureManager.g_pettingListener = this.GestureListener; m_gestureManager.SetPettingDelegate(this); CameraController.Instance.SetPettingDelegate(this); //m_gestureManager.DisableGestures(); // init bridge items m_sheepManager = GameObject.Find("SheepManager").GetComponent<SheepManager>(); m_sheepManager.InitializeSheep(); // init dragon collider GameObject HeadCollider = (GameObject)Resources.Load("Prefabs/Petting/DragonColliders/HeadCollider"); GameObject BodyCollider = (GameObject)Resources.Load("Prefabs/Petting/DragonColliders/BodyCollider"); m_dragonHeadCollider = GameObject.Instantiate(HeadCollider) as GameObject; m_dragonBodyCollider = GameObject.Instantiate(BodyCollider) as GameObject; m_dragonHeadCollider.transform.parent = m_petDragon.transform.Find("joint_Spine/joint_Neck/joint_Head").transform; m_dragonHeadCollider.name = "HeadCollider"; m_dragonHeadCollider.transform.localPosition = new Vector3(-0.00785967f, -0.03883493f, 0.2275544f); m_dragonHeadCollider.transform.localRotation = Quaternion.Euler(new Vector3(335.4119f, 184.195f, 1.887401f)); m_dragonHeadCollider.transform.localScale = new Vector3(0.6969064f, 0.4911779f, 1.063113f); m_dragonBodyCollider.transform.parent = m_petDragon.transform.Find("joint_Spine").transform; m_dragonBodyCollider.name = "BodyCollider"; m_dragonBodyCollider.transform.localPosition = new Vector3(0.0176101f, -0.2866409f, -0.8635432f); m_dragonBodyCollider.transform.localRotation = Quaternion.Euler(new Vector3(270.0f, 180.0f, 0.0f)); //m_dragonBodyCollider.transform.localScale = new Vector3(1.043613f, 1.421112f, 1.043613f); //init camera focus point m_cameraFocusPoint = new GameObject ( "FocusPoint" ); m_cameraFocusPoint.tag = "ToothlessFocusPoint"; GameObject toothlessAxis = GameObject.Find("joint_Spine"); m_cameraFocusPoint.transform.parent = toothlessAxis.transform; m_cameraFocusPoint.transform.position = toothlessAxis.transform.position; m_cameraFocusPoint.transform.rotation = Quaternion.identity; //Sound audio source container m_headSoundContainer = new GameObject( "SoundContainer_Head" ); m_headSoundContainer.transform.parent = toothlessAxis.transform; m_headSoundContainer.transform.position = toothlessAxis.transform.position; m_headSoundContainer.transform.rotation = Quaternion.identity; m_bodySoundContainer = new GameObject( "SoundContainer_Body" ); m_bodySoundContainer.transform.parent = toothlessAxis.transform; m_bodySoundContainer.transform.position = toothlessAxis.transform.position; m_bodySoundContainer.transform.rotation = Quaternion.identity; m_headAndBodySoundContainer = new GameObject( "SoundContainer_HeadAndBody" ); m_headAndBodySoundContainer.transform.parent = toothlessAxis.transform; m_headAndBodySoundContainer.transform.position = toothlessAxis.transform.position; m_headAndBodySoundContainer.transform.rotation = Quaternion.identity; // Camera Look Points GameObject cHead = new GameObject( "CamPlayerHead" ); GameObject cBody = new GameObject( "CamPlayerBody" ); GameObject cLeft = new GameObject( "CamPlayerLeft" ); GameObject cRight = new GameObject( "CamPlayerRight" ); cHead.tag = "CamPlayerHead"; cBody.tag = "CamPlayerBody"; cLeft.tag = "CamPlayerLeft"; cRight.tag = "CamPlayerRight"; cHead.transform.parent = m_mainCamera.gameObject.transform; cBody.transform.parent = m_mainCamera.gameObject.transform; cLeft.transform.parent = m_mainCamera.gameObject.transform; cRight.transform.parent = m_mainCamera.gameObject.transform; cHead.transform.localPosition = new Vector3( 0.0f, 0.30f, 0.0f ); cBody.transform.localPosition = new Vector3( 0.0f, -0.30f, 0.0f ); cLeft.transform.localPosition = new Vector3( -1.2f, 0.0f, 0.0f ); cRight.transform.localPosition = new Vector3( 1.2f, 0.0f, 0.0f ); cHead.transform.localScale = new Vector3( 0.001f, 0.001f, 0.001f ); cBody.transform.localScale = new Vector3( 0.001f, 0.001f, 0.001f ); cLeft.transform.localScale = new Vector3( 0.001f, 0.001f, 0.001f ); cRight.transform.localScale = new Vector3( 0.001f, 0.001f, 0.001f ); // Dragon Look Points GameObject lookL = new GameObject( "DLookL" ); GameObject lookR = new GameObject( "DLookR" ); lookL.tag = "DLookL"; lookR.tag = "DLookR"; lookL.transform.parent = m_petDragon.transform; lookL.transform.position = new Vector3( 3.50f, 2.00f, -1.00f ); lookR.transform.parent = m_petDragon.transform; lookR.transform.position = new Vector3( -3.50f, 2.00f, -1.00f ); // init ui m_uiRefs = new Hashtable(); m_carePlayUI = GameObject.Find("CareAndPlayHUD") as GameObject; m_carePlayUI.GetComponent<CareAndPlayHUD>(); m_carePlayUI.GetComponent<GamePauseManager>().PauseCallBack = this.PauseGame; m_carePlayTab = GameObject.Find("MainTab") as GameObject; m_uiManager = m_carePlayUI.AddComponent<CarePlayUIManager>(); m_uiManager.Initialize(); m_uiManager.SetCB_Call(this.OnDragonCall); m_uiManager.SetCB_Book(this.OnBookOfDragon); m_uiManager.SetCB_Inventory(this.OnInventory); m_uiManager.SetCB_Inventory_Close(this.OnInventoryClose); m_uiManager.SetCB_Map(this.OnMap); m_uiManager.SetCB_Profile(this.OnProfile); m_uiManager.SetCB_Profile_Close(this.OnProfileClose); m_tabManager = m_carePlayTab.GetComponent<CarePlayTabManager>(); m_energyGauge = GameObject.Find("EnergyProgress") as GameObject; m_bondGauge = GameObject.Find("BondProgress") as GameObject; m_energyBondUI = GameObject.Find("EnergyBond") as GameObject; m_pauseUI = GameObject.Find("PauseBTN") as GameObject; StatsManager.Instance.EnergyGauge = m_energyGauge.GetComponent<EnergyProgress>(); StatsManager.Instance.BondGauge = m_bondGauge.GetComponent<BondProgress>(); // UI finger tap m_uiFingerSingleTap = GameObject.Find("SingleTapFinger") as GameObject; m_uiFingerDoubleTap = GameObject.Find("DoubleTapFinger") as GameObject; m_uiFingerHold = GameObject.Find("HoldFinger") as GameObject; m_uiFingerSingleTap.transform.parent.localPosition = new Vector3( -6.043911e-05f, 319.0215f, 0f ); m_uiFingerSingleTap.SetActive(false); m_uiFingerDoubleTap.SetActive(false); m_uiFingerHold.SetActive(false); // set inventory callbacks InventoryUIHandler.OnFeedingItemCallback = this.OnFeedingItem; InventoryUIHandler.OnFetchingItemCallback = this.OnFetchingItem; InventoryUIHandler.OnCarePlayItemCallback = this.OnCarePlayItem; // set Hud Callback to enable gestures //m_carePlayUI.GetComponent<CareAndPlayHUD>().SetDialogCloseCB(m_gestureManager.EnableGestures); // init dragon animation controller m_dragonAnimScript = m_petDragon.gameObject.GetComponent<DragonScript>(); m_dragonAnimScript.SetPettingDelegate(this); // init dragon animation m_dragonAnimation = m_petDragon.gameObject.GetComponent<DragonAnimation>(); m_dragonAnimation.SetPettingDelegate(this); m_petDragon.GetComponent<JawCruncherStateController>().SetPettingDelegate( this ); // init dragon animation tool DragonAnimationQueue.getInstance().SetDAnim(m_petDragon.gameObject.GetComponent<DragonAnimation>()); DragonAnimationQueue.getInstance().SetPettingDelegate(this); // initialize DragonStateMachine m_dragonStateMachine = m_petDragon.gameObject.GetComponent<Dragon>(); m_dragonStateMachine.SetPettingDelegate(this); m_dragonStateMachine.Initialize(); // initialize DragonScript m_dragonAnimScript.Initialize(); // Setup Pausables m_petDragon.AddComponent<Pausable>(); m_mainCamera.AddComponent<Pausable>(); // reset values StatsManager.Instance.DragonMode = StatsManager.MODE_NORMAL; // - LA //StatsManager.Instance.DragonMode = StatsManager.MODE_ACT1; // - LA // on start of touchplay, always set interactive to true m_dragonStateMachine.SetIsInteractible(true); // Swipe UI m_swipeUI = GameObject.Find("SwipeUI"); m_swipeHolder = GameObject.Find("SwipeHolder"); m_swipeFingerGO = GameObject.Find("SwipeFinger"); m_swipeFinger = m_swipeFingerGO.GetComponent<TweenPosition>(); m_swipeUITexture = m_swipeUI.GetComponent<UITexture>(); m_swipeUITexture.alpha = 0.3f; m_swipeHolder.SetActive(false); m_swipeUI.GetComponent<UITexture>().alpha = 0.5f; m_swipeFingerGO.GetComponent<UITexture>().alpha = 0.75f; //Double Tap UI m_doubleTapTweenPos = GameObject.Find("DoubleTapUI").GetComponent<TweenPosition>(); GameObject successIcon = GameObject.Find("SuccesIcon"); UISprite spriteSucccessIcon = successIcon.GetComponent<UISprite>(); spriteSucccessIcon.alpha = 0.0f; m_successIconTweenAlpha = successIcon.GetComponent<TweenAlpha>(); m_successIconTweenAlpha.onFinished=ResetSuccesAnimation; // hide UIs this.HideUI("DCall"); // Handle Timer for Usage Tracker m_usageTrackerScheduler = S6Scheduler.ScheduleAction( this, StatsManager.Instance.UpdateTrackers, 0.5f, S6Scheduler.INFINITE, false); // update dragon mood for Animation Controllers StatsManager.Instance.UpdateMood(); // load objects // fish m_fishItems.Add(this.CreateObject( "Fish", "Prefabs/Feeding/FeedingFish", 1.0f)); // chicken m_chickenItems.Add(this.CreateObject( "ChickenLeg", "Prefabs/Feeding/FeedingChickenLeg", 1.0f)); m_chickenItems.Add(this.CreateObject( "ChickenThigh", "Prefabs/Feeding/FeedingChickenThigh", 1.0f)); m_chickenItems.Add(this.CreateObject( "ChickenWing", "Prefabs/Feeding/FeedingChickenWing", 1.0f)); // seafood m_seafoodItems.Add(this.CreateObject( "Crab", "Prefabs/Feeding/FeedingCrab", 1.0f)); m_seafoodItems.Add(this.CreateObject( "Lobster", "Prefabs/Feeding/FeedingLobster", 1.0f)); m_seafoodItems.Add(this.CreateObject( "Shrimp", "Prefabs/Feeding/FeedingShrimp", 1.0f)); // fruits & veggies m_fruitsAndVeggiesItems.Add(this.CreateObject( "FruitsAndVeggies", "Prefabs/Feeding/FeedingOrange", 1.0f)); m_fruitsAndVeggiesItems.Add(this.CreateObject( "FruitsAndVeggies", "Prefabs/Feeding/FeedingPeach", 1.0f)); m_fruitsAndVeggiesItems.Add(this.CreateObject( "FruitsAndVeggies", "Prefabs/Feeding/FeedingTurnip", 1.0f)); // fetching items m_fetchingItems.Add(this.CreateObject( "Boomerang", "Prefabs/Fetching/Boomerang", 1.0f)); // adjust boomerang transform m_fetchingItems[0].transform.parent = Camera.main.transform; m_fetchingItems[0].transform.localPosition = new Vector3( -0.05178565f, -0.51644f, 1.536007f ); m_fetchingItems[0].transform.localRotation = Quaternion.Euler(new Vector3( 0.0f, 283.0f, 69.99999f )); // Handle disable/enable of gestures during hide/show of overlays // These methods are called during the initial add & remove of overlays. ScreenManager.Instance.OnDisplayOverlay = () => { switch( TutorialController.GTutState ) { case TutorialController.ETutorialState.BondMeterIntro: case TutorialController.ETutorialState.PlayerProfileIntro: // don't update gestures during this state of tutorial break; default: m_gestureManager.DisableGestures(); break; } }; ScreenManager.Instance.OnHideOverlay = () => { switch( TutorialController.GTutState ) { case TutorialController.ETutorialState.BondMeterIntro: case TutorialController.ETutorialState.PlayerProfileIntro: // don't update gestures during this state of tutorial break; default: m_gestureManager.EnableGestures(); break; } }; // Check Scenes this.HandleScenes(); }
public void OnDestroy () { StatsManager.Instance.ResetDragonStatus(); m_instance = null; m_usageTrackerScheduler.StopScheduler(); m_usageTrackerScheduler.StopCoroutine(); m_usageTrackerScheduler = null; Pausable.Reset(); }
public void Initialize () { this.SetIsInteractible(true); #if ( DEBUG_OFF_IDLE_ON_MIDGROUND ) S6Scheduler.ScheduleAction( this, () => { //this.Reaction("Type_Events", "Event_Idle_Midground"); //this.Reaction("Type_Cove_Sequence_Opening", "Event_Camera_Pan"); //this.Reaction("Type_Cove_Sequence_Opening", "Event_Petting_Cue"); //this.Reaction("Type_Cove_Sequence_Opening", "Event_Play_More"); //this.Reaction("Type_Cove_Sequence_Opening", "Event":"Event_Petting_Cue"); //this.Reaction("Type_Roam", "Event_Roam"); }, 1.0f, 1, false); #endif // Game Timer m_timeOnCove = S6Scheduler.ScheduleAction(this, () => { // sanity check.. dont resume if on tutorial mode if( TutorialController.IsInTutorialMode ) { return; } // Temporary commented for Sprint 9 Demove StatsManager.Instance.coveTime += 1.0f; //this.TimedReaction("Type_Anim_Cue_Events", "Event_Animation_Cues"); this.TimedReaction( "Type_CoveTime_Based", "Event_Idle_Batch3_To_5_Distant" ); this.TimedReaction( "Type_CoveTime_Based", "Event_Idle_Batch3_To_5_Friendly" ); this.TimedReaction( "Type_CoveTime_Based", "Event_Idle_Batch3_To_5_Close" ); this.TimedReaction( "Type_CoveTime_Based", "Event_Idle_Batch3_To_5_Deep" ); }, 1.0f, S6Scheduler.INFINITE, false); // Tutorial Timer m_tutorialTimer = S6Scheduler.ScheduleAction(this, () => { if ( m_tutorialTimer != null ) { if ( TutorialController.GTutState != TutorialController.ETutorialState.PostPetting ) { return; } if ( CarePlayNFController.GetPetAnimController().IsCurAnimStateOnSub(ERigType.Body, ECP_SubState.TouchMoment, "TouchMomentWaitingIdle" ) ) { StatsManager.Instance.WaitingTime += 1.0f; StatsManager.Instance.TouchMomentTime += 1.0f; this.TimedReaction( "Type_Time_Based", "Event_Ignoring_Toothless" ); if( StatsManager.Instance.TouchMomentTime == 15.0f ) { PettingMain.Instance.ShowTapFingerGuide(3); } } } }, 1.0f, S6Scheduler.INFINITE, false); // Event Timer m_eventTimer = S6Scheduler.ScheduleAction(this, () => { // sanity check.. dont resume if on tutorial mode if ( TutorialController.IsInTutorialMode ) { return; } // Temporary commented for Sprint 9 Demove StatsManager.Instance.eventTime += 1.0f; StatsManager.Instance.bucketTime += 1.0f; this.TimedReaction("Type_Time_Based", "Event_No_User_Interaction"); this.TimedReaction("Type_Time_Based", "Event_Back_To_Stand"); /* //this.TimedReaction("Type_Time_Based", "Event_Idle_Stand"); //this.TimedReaction("Type_Time_Based", "Event_Idle_Sit"); //*/ /** Scott Demo Mode this.TimedReaction("Type_Sprint_8_Demo", "Event_Idle_Sit_1"); this.TimedReaction("Type_Sprint_8_Demo", "Event_Idle_Look_Around"); this.TimedReaction("Type_Sprint_8_Demo", "Event_Idle_Sit_2"); this.TimedReaction("Type_Sprint_8_Demo", "Event_Sratch"); this.TimedReaction("Type_Sprint_8_Demo", "Event_Idle_Sit_3"); this.TimedReaction("Type_Sprint_8_Demo", "Event_Chase_tail"); this.TimedReaction("Type_Sprint_8_Demo", "Event_Idle_Sit_4"); this.TimedReaction("Type_Sprint_8_Demo", "Event_Walk_Batch_3"); //*/ }, 1.0f, S6Scheduler.INFINITE, false); // Meter Update every 2 sec m_statusUpdater = S6Scheduler.ScheduleAction(this, () => { // sanity check.. dont resume if on tutorial mode if ( TutorialController.IsInTutorialMode ) { return; } /* StatsManager.Instance.CheckAffectedMetersByMeter("Thirsty"); StatsManager.Instance.CheckAffectedMetersByMeter("Sick"); StatsManager.Instance.CheckAffectedMetersByMeter("Dental"); StatsManager.Instance.CheckAffectedMetersByMeter("Dirty"); StatsManager.Instance.CheckAffectedMetersByMeter("Energy"); //*/ }, 2.0f, S6Scheduler.INFINITE, false); #if DEBUG_DRAGON_CALL_ACTI0N m_sprint9DemoCounter = 3; m_roamBgCounter = 10; #endif m_idleTimer = S6Scheduler.ScheduleAction( this, () => { // if not in tutorial state if( TutorialController.GTutState == TutorialController.ETutorialState.Invalid || TutorialController.GTutState == TutorialController.ETutorialState.Done || TutorialController.GTutState == TutorialController.ETutorialState.Cinematic || TutorialController.GTutState == TutorialController.ETutorialState.TutorialCPart2 && !( AccountManager.Instance.EnergyMeter <= m_lowMeterLimit || AccountManager.Instance.ThirstMeter <= m_lowMeterLimit || AccountManager.Instance.DirtyMeter <= m_lowMeterLimit || AccountManager.Instance.BoredMeter <= m_lowMeterLimit || AccountManager.Instance.SickMeter <= m_lowMeterLimit || AccountManager.Instance.DentalMeter <= m_lowMeterLimit ) && StatsManager.Instance.DragonPlace == "Middleground" ) { //this.TimedReaction("Type_Sprint_9_Demo", "Event_Custom_Batch_3"); } }, 30.0f, S6Scheduler.INFINITE, false); // +KJ:09192013 Temp. off the update of meters by time. //m_statusUpdater.PauseScheduler(); m_batch2Counter = 0; m_batch2Pattern = new List<string>(); m_batch2Pattern.Add("Event_Custom_Batch_2_LookAround"); m_batch2Pattern.Add("Event_Custom_Batch_2_Scratching"); m_batch2Pattern.Add("Event_Custom_Batch_2_ChaseTail"); m_roamBgCounter = 0; m_sprint9Demo = S6Scheduler.ScheduleAction(this, () => { // sanity check.. dont resume if on tutorial mode if ( TutorialController.IsInTutorialMode ) { return; } //Debug.Log("Timer:"+m_sprint9DemoCounter); //if( !m_isInteractible ) // return; m_roamBgCounter++; if ( m_sprint9DemoCounter <= 3 ) { this.TimedReaction("Type_Sprint_9_Demo", m_batch2Pattern[m_batch2Counter]); m_batch2Counter++; m_sprint9DemoCounter++; if ( m_batch2Counter > 2 ) { m_batch2Counter = 0; //Utility.ShuffleList<string>(batch2Pattern); // + LA } } else if ( m_sprint9DemoCounter > 3 ) { // Energy, Thirsty, Dirty, Bored, Sick, Dental if( AccountManager.Instance.EnergyMeter <= m_lowMeterLimit || AccountManager.Instance.ThirstMeter <= m_lowMeterLimit || AccountManager.Instance.DirtyMeter <= m_lowMeterLimit || AccountManager.Instance.BoredMeter <= m_lowMeterLimit || AccountManager.Instance.SickMeter <= m_lowMeterLimit || AccountManager.Instance.DentalMeter <= m_lowMeterLimit ) { Debug.Log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n"); Debug.Log("- PLAYING ANIMATION CUE - Type_Sprint_9_Demo::Event_Custom_Cues \n"); Debug.Log("--------------------------------------------- \n"); //Debug.Break(); this.TimedReaction("Type_Sprint_9_Demo", "Event_Custom_Cues"); m_batch2Counter = 0; m_sprint9DemoCounter = 0; } else { // New Integration of Idle Animations this.TimedReaction("Type_Sprint_9_Demo", "Event_Custom_Idle"); m_sprint9DemoCounter = 0; m_roamBgCounter = 0; } m_sprint9DemoCounter = 0; m_batch2Counter = 0; } }, 2.5f, S6Scheduler.INFINITE, false); }