public void SpawnPixies(Mobile target) { Map map = Map; if (map == null) return; int newPixies = Utility.RandomMinMax(3, 6); for (int i = 0; i < newPixies; ++i) { var pixie = new Pixie {Team = Team, FightMode = FightMode.Closest}; Point3D loc = Location; for (int j = 0; j < 10; ++j) { int x = X + Utility.Random(3) - 1; int y = Y + Utility.Random(3) - 1; int z = map.GetAverageZ(x, y); if (false == map.CanFit(x, y, Z, 16, false, false)) loc = new Point3D(x, y, Z); else if (false == map.CanFit(x, y, z, 16, false, false)) loc = new Point3D(x, y, z); } pixie.MoveToWorld(loc, map); pixie.Combatant = target; } }
public override void dragStop(ref GestureRecognition gr, ref Pixie pixie) { int gesture_id = gr.endStroke(ref similarity, ref pos, ref scale, ref dir0, ref dir1, ref dir2); if (gesture_id == gestureid_flip) { pixie.triggerFlip(pos, dir0); this.num_commands_issued += 1; Sample_Pixie.HUDText.text = "That's your new gesture. Nice!\nTry it a few more times.\n(" + this.num_commands_issued + "/4)"; } else if (gesture_id == gestureid_spin) { pixie.triggerSpin(pos); Sample_Pixie.HUDText.text = "That's a 'spin' gesture. Nice!\nTry a few more times.\n(" + this.num_commands_issued + "/4)"; } else if (gesture_id == gestureid_go) { pixie.triggerGo(pos + (dir0 * 6.0f * (float)scale)); Sample_Pixie.HUDText.text = "That's a 'go there' gesture. Nice!\nTry a few more times.\n(" + this.num_commands_issued + "/4)"; } else if (gesture_id == gestureid_come) { pixie.triggerCome(pos); Sample_Pixie.HUDText.text = "That's a 'come here' gesture. Nice!\nTry a few more times.\n(" + this.num_commands_issued + "/4)"; } if (this.num_commands_issued >= 4) { this.completed = true; Sample_Pixie.HUDText.text = ""; } }
public override void dragStop(ref GestureRecognition gr, ref Pixie pixie) { int gesture_id = gr.endStroke(ref similarity, ref pos, ref scale, ref dir0, ref dir1, ref dir2); if (gesture_id == gestureid_peekaboo) { pixie.triggerPeekaboo(); Sample_Pixie.HUDText.text = "That's your new gesture. Awesome!\nFeel try to try out any gesture."; } else if (gesture_id == gestureid_flip) { pixie.triggerFlip(pos, dir0); Sample_Pixie.HUDText.text = "That's your previous gesture. Cool!\nFeel try to try out any gesture."; } else if (gesture_id == gestureid_spin) { pixie.triggerSpin(pos); Sample_Pixie.HUDText.text = "That's a 'spin' gesture. Nice!\nFeel try to try out any gesture."; } else if (gesture_id == gestureid_go) { pixie.triggerGo(pos + (dir0 * 6.0f * (float)scale)); Sample_Pixie.HUDText.text = "That's a 'go there' gesture. Splended!\nMake it larger to send the pixie further away."; } else if (gesture_id == gestureid_come) { pixie.triggerCome(pos); Sample_Pixie.HUDText.text = "That's a 'come here' gesture. Not bad!\nFeel try to try out any gesture."; } }
public void SpawnPixies( Mobile target ) { Map map = this.Map; if ( map == null ) return; int newPixies = Utility.RandomMinMax( 3, 6 ); for ( int i = 0; i < newPixies; ++i ) { Pixie pixie = new Pixie(); pixie.Team = this.Team; pixie.FightMode = FightMode.Closest; bool validLocation = false; Point3D loc = this.Location; for ( int j = 0; !validLocation && j < 10; ++j ) { int x = X + Utility.Random( 3 ) - 1; int y = Y + Utility.Random( 3 ) - 1; int z = map.GetAverageZ( x, y ); if ( validLocation = map.CanFit( x, y, this.Z, 16, false, false ) ) loc = new Point3D( x, y, Z ); else if ( validLocation = map.CanFit( x, y, z, 16, false, false ) ) loc = new Point3D( x, y, z ); } pixie.MoveToWorld( loc, map ); pixie.Combatant = target; } }
protected override void OnNextMove() { base.OnNextMove(); Pixie p = (ParentThing as Pixie); if (!p.CollidesWithBackground(UP_VECTOR)) { TargetMove = UP_VECTOR; } }
/// <summary> /// Init: pixie herself (a default implementation is in Level) /// </summary> protected virtual void InitPixie() { pixie = new Pixie(); pixie.PositionAndTarget = PIXIE_STARTING_POS; pixie.TargetSpeed = PIXIE_TARGETSPEED; Add(pixie); keyControl = new PixieKeyControl(); pixie.Add(keyControl); }
public override void dragStop(ref GestureRecognition gr, ref Pixie pixie) { this.completed = true; Sample_Pixie.HUDText.text = ""; // reparent the text to be static in front Transform hud_text_transform = GameObject.Find("Canvas").transform; hud_text_transform.SetParent(GameObject.Find("XR Rig").transform, true); hud_text_transform.rotation.SetLookRotation(GameObject.Find("Main Camera").transform.position - hud_text_transform.position); }
public TitleScreen() { bg = new RotatingBackground("psych"); bg.Motion.Scale = 20.0f; bg.StartTime = 0f;// 9.09f; Add(bg); pixie = new Pixie(); pixie.Motion.Position = new Vector2(0.666f, 0.0f); pixie.Motion.Scale = 20.0f; pixie.Duration = TIME_LOGO_APPEAR; Add(pixie); cuteText = new SubtitleText(new string[] { "She's pink...", " She's cute...", " She's all square!" }, new float[] { 1.5f, 3.5f, 5.5f }, false); cuteText.Motion.Position = new Vector2(0.26f, 0.62f); cuteText.Duration = TIME_LOGO_APPEAR; Add(cuteText); /* * helpText = new SubtitleText("SPACE Play!\n C Credits\n ESC Exit"); * helpText.StartTime = 13.5f; * helpText.Motion.Scale = 0.7f; * helpText.DrawInfo.DrawColor = Color.AntiqueWhite; * helpText.Motion.Position = new Vector2(0.2f, 0.6f); * Add(helpText); */ helpText = new Spritelet("showControls"); helpText.StartTime = TIME_LOGO_APPEAR; helpText.Motion.Scale = 1f; helpText.Motion.Position = new Vector2(0.666f, 0.85f); Add(helpText); pixieLogo = new PixieLogo("pixielogo"); pixieLogo.Motion.Scale = 20.0f; pixieLogo.Motion.Position = new Vector2(0.666f, 0.35f); pixieLogo.StartTime = TIME_LOGO_APPEAR; Add(pixieLogo); MotionB = new MotionBehavior(); Add(MotionB); creditsScreen = new Thing("credits.png"); Add(creditsScreen); creditsScreen.Visible = false; /* * ttLogo = new Spritelet("tt-logo-4"); * ttLogo.Motion.Position = new Vector2(1.05f, 0.02f); * Add(ttLogo); */ }
public override void dragStop(ref GestureRecognition gr, ref Pixie pixie) { int gesture_id = gr.endStroke(ref similarity, ref pos, ref scale, ref dir0, ref dir1, ref dir2); if (gesture_id == gestureid_go) { pixie.triggerGo(pos + (dir0 * 6.0f * (float)scale)); this.completed = true; Sample_Pixie.HUDText.text = ""; } }
protected override void OnUpdate(ref TTengine.Core.UpdateParams p) { base.OnUpdate(ref p); Pixie hero = Level.Current.pixie; Vector2 dif = (hero.Position - Position); if (dif.Length() < 8.5f) { dif.Normalize(); Vector2 smiteVector = dif * p.Dt * 25f; hero.Target += smiteVector; } }
public override void dragStop(ref GestureRecognition gr, ref Pixie pixie) { int gesture_id = gr.endStroke(ref similarity, ref pos, ref scale, ref dir0, ref dir1, ref dir2); if (gesture_id == gestureid_peekaboo) { recorded_samples += 1; Sample_Pixie.HUDText.text = "Let's try it again!\nInvent a new gesture and do it 20 times.\n(" + recorded_samples + "/20)"; } if (recorded_samples >= 20) { this.completed = true; gr.startTraining(); Sample_Pixie.HUDText.text = "Please wait while your pixie is learning the new gesture..."; } }
public override void dragStop(ref GestureRecognition gr, ref Pixie pixie) { int gesture_id = gr.endStroke(ref similarity, ref pos, ref scale, ref dir0, ref dir1, ref dir2); if (gesture_id == gestureid_spin) { pixie.triggerSpin(pos); this.num_commands_issued += 1; Sample_Pixie.HUDText.text = "Great!\nTry it again!\nMake a twirl (whirling) gesture\nto make the pixie spin. (" + this.num_commands_issued + "/3)"; } if (this.num_commands_issued >= 3) { this.completed = true; Sample_Pixie.HUDText.text = ""; } }
public void SpawnPixies(Mobile target) { Map map = Map; if (map == null) { return; } int newPixies = Utility.RandomMinMax(3, 6); for (int i = 0; i < newPixies; ++i) { Pixie pixie = new Pixie { Team = Team, FightMode = FightMode.Closest }; bool validLocation = false; Point3D loc = Location; for (int j = 0; !validLocation && j < 10; ++j) { int x = X + Utility.Random(3) - 1; int y = Y + Utility.Random(3) - 1; int z = map.GetAverageZ(x, y); if (validLocation = map.CanFit(x, y, Z, 16, false, false)) { loc = new Point3D(x, y, Z); } else if (validLocation = map.CanFit(x, y, z, 16, false, false)) { loc = new Point3D(x, y, z); } } pixie.MoveToWorld(loc, map); pixie.Combatant = target; } }
public void SpawnPixies(Mobile target) { var map = Map; if (map == null) { return; } var newPixies = Utility.RandomMinMax(3, 6); for (var i = 0; i < newPixies; ++i) { var pixie = new Pixie { Team = Team, FightMode = FightMode.Closest }; pixie.MoveToWorld(map.GetRandomNearbyLocation(Location), map); pixie.Combatant = target; } }
// Initialization: void Start() { pixie = new Pixie(); // Set the welcome message. HUDText = GameObject.Find("HUDText").GetComponent <Text>(); current_step = new Step0_PressTrigger(); current_step.init(ref gr); me = GCHandle.Alloc(this); const string LoadGesturesFile = "Sample_Pixie_Gestures.dat"; // Find the location for the gesture database (.dat) file #if UNITY_EDITOR // When running the scene inside the Unity editor, // we can just load the file from the Assets/ folder: string gesture_file_path = "Assets/GestureRecognition"; #elif UNITY_ANDROID // On android, the file is in the .apk, // so we need to first "download" it to the apps' cache folder. AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject activity = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity"); string gesture_file_path = activity.Call <AndroidJavaObject>("getCacheDir").Call <string>("getCanonicalPath"); UnityWebRequest request = UnityWebRequest.Get(Application.streamingAssetsPath + "/" + LoadGesturesFile); request.SendWebRequest(); while (!request.isDone) { // wait for file extraction to finish } if (request.isNetworkError) { HUDText.text = "Failed to extract sample gesture database file from apk.\n"; return; } File.WriteAllBytes(gesture_file_path + "/" + LoadGesturesFile, request.downloadHandler.data); #else // This will be the case when exporting a stand-alone PC app. // In this case, we can load the gesture database file from the streamingAssets folder. string gesture_file_path = Application.streamingAssetsPath; #endif int ret = gr.loadFromFile(gesture_file_path + "/" + LoadGesturesFile); if (ret != 0) { HUDText.text = $"Failed to load sample gesture database file ({ret})\n"; //return; } // Hide unused models in the scene GameObject controller_oculus_left = GameObject.Find("controller_oculus_left"); GameObject controller_oculus_right = GameObject.Find("controller_oculus_right"); GameObject controller_vive_left = GameObject.Find("controller_vive_left"); GameObject controller_vive_right = GameObject.Find("controller_vive_right"); GameObject controller_microsoft_left = GameObject.Find("controller_microsoft_left"); GameObject controller_microsoft_right = GameObject.Find("controller_microsoft_right"); GameObject controller_dummy_left = GameObject.Find("controller_dummy_left"); GameObject controller_dummy_right = GameObject.Find("controller_dummy_right"); controller_oculus_left.SetActive(false); controller_oculus_right.SetActive(false); controller_vive_left.SetActive(false); controller_vive_right.SetActive(false); controller_microsoft_left.SetActive(false); controller_microsoft_right.SetActive(false); controller_dummy_left.SetActive(false); controller_dummy_right.SetActive(false); var input_devices = new List <UnityEngine.XR.InputDevice>(); UnityEngine.XR.InputDevices.GetDevices(input_devices); String input_device = ""; foreach (var device in input_devices) { if (device.characteristics.HasFlag(InputDeviceCharacteristics.HeadMounted)) { input_device = device.name; break; } } if (input_device.Length >= 6 && input_device.Substring(0, 6) == "Oculus") { controller_oculus_left.SetActive(true); controller_oculus_right.SetActive(true); } else if (input_device.Length >= 4 && input_device.Substring(0, 4) == "Vive") { controller_vive_left.SetActive(true); controller_vive_right.SetActive(true); } else if (input_device.Length >= 4 && input_device.Substring(0, 4) == "DELL") { controller_microsoft_left.SetActive(true); controller_microsoft_right.SetActive(true); } else // { controller_dummy_left.SetActive(true); controller_dummy_right.SetActive(true); } GameObject star = GameObject.Find("star"); star.transform.localScale = new Vector3(0.0f, 0.0f, 0.0f); }
public override void Damage(Mobile m) { base.Damage(m); if (m.Alive) { Item item = m.FindItemOnLayer(Layer.OuterTorso); if (item is GMRobe) { AOS.Damage(m, 0, 0, 0, 0, 0, 0); } else { // Forest noises if (Utility.RandomDouble() < 0.008) { m.PlaySound(Utility.RandomList(0x000, 0x001, 0x002)); AOS.Damage(m, 0, 0, 0, 0, 0, 0); } // Bird chirps if (Utility.RandomDouble() < 0.002) { m.PlaySound(Utility.RandomList(0x094, 0x095, 0x096, 0x097, 0x0D1, 0x0D2)); AOS.Damage(m, 0, 0, 0, 0, 0, 0); } // Random Encounter 1 if (Utility.RandomDouble() < 0.003) { if (m.Map == Map.Malas) { int x1 = m.X + 8; int y1 = m.Y + 8; int z1 = Map.Malas.GetAverageZ(x1, y1); if (Map.Malas.CanSpawnMobile(x1, y1, z1)) { BaseCreature encountera; switch (Utility.Random(11)) { default: case 0: encountera = new AlytharrForestHart(); break; case 1: encountera = new AlytharrGrassSnake(); break; case 2: encountera = new BlackLizard(); break; case 3: encountera = new Centaur(); break; case 4: encountera = new HillToad(); break; case 5: encountera = new MinorBloodElemental(); break; case 6: encountera = new Pixie(); break; case 7: encountera = new WyvernYoungling(); break; case 8: encountera = new BlackBear(); break; case 9: encountera = new Crane(); break; case 10: encountera = new Panther(); break; } encountera.MoveToWorld(new Point3D(x1, y1, z1), Map.Malas); AOS.Damage(m, 0, 0, 0, 0, 0, 0); Timer.DelayCall(TimeSpan.FromMinutes(10.0), new TimerStateCallback(DeleteEncounterA), encountera); } } } // Random Encounter 2 if (Utility.RandomDouble() < 0.003) { if (m.Map == Map.Malas) { int x2 = m.X - 8; int y2 = m.Y - 8; int z2 = Map.Malas.GetAverageZ(x2, y2); if (Map.Malas.CanSpawnMobile(x2, y2, z2)) { BaseCreature encountera; switch (Utility.Random(11)) { default: case 0: encountera = new AlytharrForestHart(); break; case 1: encountera = new AlytharrGrassSnake(); break; case 2: encountera = new BlackLizard(); break; case 3: encountera = new Centaur(); break; case 4: encountera = new HillToad(); break; case 5: encountera = new MinorBloodElemental(); break; case 6: encountera = new Pixie(); break; case 7: encountera = new WyvernYoungling(); break; case 8: encountera = new BlackBear(); break; case 9: encountera = new Crane(); break; case 10: encountera = new Panther(); break; } encountera.MoveToWorld(new Point3D(x2, y2, z2), Map.Malas); AOS.Damage(m, 0, 0, 0, 0, 0, 0); Timer.DelayCall(TimeSpan.FromMinutes(10.0), new TimerStateCallback(DeleteEncounterA), encountera); } } } // Random Treasure Chest 1 if (Utility.RandomDouble() < 0.0005) { if (m.Map == Map.Malas) { int x1 = m.X + 12; int y1 = m.Y + 12; int z1 = Map.Malas.GetAverageZ(x1, y1); if (Map.Malas.CanSpawnMobile(x1, y1, z1)) { BaseContainer treasurechest; if (m.Skills.Tracking.Base > 9.9) { switch (Utility.Random(2)) { default: case 0: treasurechest = new AlytharrRegionTreasureChest1(); break; case 1: treasurechest = new AlytharrRegionTreasureChest1(); break; } treasurechest.MoveToWorld(new Point3D(x1, y1, z1), Map.Malas); AOS.Damage(m, 0, 0, 0, 0, 0, 0); Timer.DelayCall(TimeSpan.FromMinutes(5.0), new TimerStateCallback(DeleteTreasureChest), treasurechest); } } } } // Random Treasure Chest 2 if (Utility.RandomDouble() < 0.0005) { if (m.Map == Map.Malas) { int x2 = m.X - 12; int y2 = m.Y - 12; int z2 = Map.Malas.GetAverageZ(x2, y2); if (Map.Malas.CanSpawnMobile(x2, y2, z2)) { BaseContainer treasurechest; if (m.Skills.Tracking.Base > 9.9) { switch (Utility.Random(2)) { default: case 0: treasurechest = new AlytharrRegionTreasureChest1(); break; case 1: treasurechest = new AlytharrRegionTreasureChest1(); break; } treasurechest.MoveToWorld(new Point3D(x2, y2, z2), Map.Malas); AOS.Damage(m, 0, 0, 0, 0, 0, 0); Timer.DelayCall(TimeSpan.FromMinutes(5.0), new TimerStateCallback(DeleteTreasureChest), treasurechest); } } } } } } }
public abstract void dragStop(ref GestureRecognition gr, ref Pixie pixie);