static void Main(string[] args) { Queue <InterFace> animals = new Queue <InterFace>(); string type; while ((type = Console.ReadLine().Trim()) != "Beast!") { string[] input = Console.ReadLine().Split(); string name = input[0]; int age = int.Parse(input[1]); string gender = input.Length == 3 ? input[2] : "none"; try { switch (type.ToLower()) { case "frog": animals.Enqueue(new Frog(name, age, gender)); break; case "dog": animals.Enqueue(new Dog(name, age, gender)); break; case "cat": animals.Enqueue(new Cat(name, age, gender)); break; case "kitten": animals.Enqueue(new Kitten(name, age)); break; case "tomcat": animals.Enqueue(new Tomcat(name, age)); break; default: throw new ArgumentException("Invalid input!"); break; } } catch (Exception ex) { Console.WriteLine(ex.Message); } } while (animals.Count != 0) { InterFace animal = animals.Dequeue(); Console.WriteLine(animal.GetType().Name); Console.WriteLine(animal.GetNameAgeGender()); Console.WriteLine(animal.ProduceSound()); } }
static void Main(string[] args) { Player m_player = new Player(); Boss m_boss = new Boss(); Mob m_mob = new Mob(); InterFace m_interface = new InterFace(); Store m_store = new Store(); if (Start(m_player)) { Console.WriteLine("\t\t\t按下任意键继续"); Console.ReadKey(); Console.Clear(); //清空屏幕 GameBackground(); //游戏背景对话 Thread.Sleep(500); Console.WriteLine("按下任意键继续"); Console.ReadKey(); Console.Clear(); m_interface.MainFace(m_player, m_boss, m_mob, m_store); } Console.ReadKey(); }
public bool TaskHandler(StoryTask task) { bool done = false; switch (task.Instruction) { case "startevolution": ZeeSterEvolutie = new ZeeSterEvolutie(); pop = ZeeSterEvolutie.GetPop(); done = true; break; case "evolve": int[] Score = new int[AgentCount]; for (int a = 0; a < AgentCount; a++) { GameObject go = pop[a].GameObject; float distance = 0; if (go != null) { distance = go.transform.position.magnitude; } Score[a] = (int)(distance); pop = ZeeSterEvolutie.Evolution(Score); } done = true; break; case "spawn": //int AgentCount = 10; for (int a = 0; a < AgentCount; a++) { // Shape input Zeester ster = pop[a]; int NumberOfLegs = ster.NumberOfLegs; int LegLength = ster.LegLength; float Hue = 1f / 7f * ster.Hue; float Sat = 1f / 7f * ster.Sat; float Val = 1f / 7f * ster.Val; // Behaviour input float Freq = (1f / 7f * ster.Freq) * 4f; float Amp = 5f + 5f * ster.Amp; //0-7 float Phase = 1f / 7f * ster.Phase; /* * int NumberOfLegs = Random.Range(1, 8); * int LegLength = Random.Range(1, 8); * float Hue = Random.Range(0f, 1f); * float Sat = Random.Range(0f, 1f); * float Val = Random.Range(0f, 1f); * * // Behaviour input * float Freq = Random.Range(0f, 4f); * float Amp = Random.Range(5f, 45f); * float Phase = Random.Range(0f, 1f); */ // Spawn // Log("h: " + Hue); GameObject body = Instantiate(BodyPrefab); ster.GameObject = body; body.transform.SetParent(Root.transform, false); body.transform.localPosition = new Vector3(0, 0, Random.Range(0f, 4f)); Agent agt = body.GetComponent <Agent>(); agt.Legs = new GameObject[NumberOfLegs]; Material newMaterial = new Material(Shader.Find("Standard")); newMaterial.color = Color.HSVToRGB(Hue, Sat, Val); //newMaterial.color = Color.red; agt.mat = newMaterial; body.GetComponentInChildren <Renderer>().material = newMaterial; for (int l = 0; l < NumberOfLegs; l++) { GameObject Leg = Instantiate(LegPrefab); Leg.transform.SetParent(body.transform, false); Leg.transform.localScale = new Vector3(1, 1, LegLength); Leg.transform.localRotation = Quaternion.Euler(10f, 360f / NumberOfLegs * l, 0); Leg.transform.GetChild(0).transform.localPosition = new Vector3(0, 0, 0.5f); agt.Legs[l] = Leg; Leg.GetComponentInChildren <Renderer>().material = newMaterial; } agt.Freq = Freq; agt.Amp = Amp; agt.Phase = Phase; } done = true; break; case "kill": foreach (Transform child in Root.transform) { Destroy(child.gameObject); } done = true; break; case "makeinterface": // Create a controller Controller = new Controller(); // Create a layout (can hold multiple planes and interfaces) MainLayout = new Layout(); // Create a plane //Plane UpperPlane3d = new Plane(GameObject.Find("UpperPlane")); //Plane LowerPlane3d = new Plane(GameObject.Find("LowerPlane")); // Create an interface UpperInterface = new InterFace(UserCanvas.gameObject, "upper"); //LowerInterface = new InterFace(UserCanvas.gameObject, "lower"); // Create a mapping and add it to the interface MainMapping = new Mapping(); MainMapping.ux_single_none += Methods.OrbitCamera; MainMapping.ux_double_none += Methods.LateralCamera; MainMapping.ux_double_none += Methods.LongitudinalCamera; MainMapping.ux_single_2d += Methods.Drag2D; MainMapping.ux_tap_2d += Methods.tapButton2D; // Create an orbit cam with a pitch constraint. Constraint orbitConstraint = new Constraint() { pitchClamp = true, pitchClampMin = 15f, pitchClampMax = 85f }; UiCam3D uppercam = new UiCam3D(GameObject.Find("MainCamera")); uppercam.AddContraint(orbitConstraint); //UiCam3D lowercam = new UiCam3D(GameObject.Find("CameraLower")); //lowercam.AddContraint(orbitConstraint); // Create an exit button and add it to the interface //button = new Button("Exit"); //button.AddConstraint(Constraint.LockInPlace(button)); //button.AddCallback("startmenu"); //UpperInterface.addButton(button); // Add together. UpperInterface.AddUiCam3D(uppercam); //LowerInterface.AddUiCam3D(lowercam); UpperInterface.AddMapping(MainMapping); //LowerInterface.AddMapping(MainMapping); //UpperPlane3d.AddInterface(UpperInterface); //LowerPlane3d.AddInterface(LowerInterface); // Add to layout MainLayout.AddInterface(UpperInterface); //MainLayout.AddPlane(UpperPlane3d); //MainLayout.AddPlane(LowerPlane3d); done = true; break; case "interface": // Update the interface(s) and get result. UserCallBack result = Controller.updateUi(MainLayout); if (result.trigger) { Log("User tapped " + result.sender + ", starting storyline " + result.label); Director.Instance.NewStoryLine(result.label); } break; case "task1": case "task2": case "task3": case "repeatingtask": if (task.GetFloatValue("wait", out wait)) { done |= Time.time > wait; } else { task.SetFloatValue("wait", Time.time + 3f); Log("Executing task " + task.Instruction); } break; case "wait5": if (task.GetFloatValue("wait", out wait)) { done |= Time.time > wait; } else { task.SetFloatValue("wait", Time.time + 5f); } break; case "wait10": if (task.GetFloatValue("wait", out wait)) { done |= Time.time > wait; } else { task.SetFloatValue("wait", Time.time + 10f); } break; default: done = true; break; } return(done); }
public bool TaskHandler(StoryTask task) { bool done = false; switch (task.Instruction) { case "makeinterface": // Create a controller Controller = new Controller(); // Create a layout (can hold multiple planes and interfaces) MainLayout = new Layout(); // Create an interface MainInterface = new InterFace(UserCanvas.gameObject, "demo"); // Create a mapping and add it to the interface MainMapping = new Mapping(); MainMapping.ux_single_2d += Methods.Drag2D; MainMapping.ux_tap_2d += Methods.tapButton2D; MainInterface.AddMapping(MainMapping); // Create locked buttons and add them to the interface Button button; button = new Button("Simple"); button.AddConstraint(Constraint.LockInPlace(button)); button.AddCallback("startsimple"); MainInterface.addButton(button); button = new Button("NetworkedServer"); button.AddConstraint(Constraint.LockInPlace(button)); button.AddCallback("startnetworkedserver"); MainInterface.addButton(button); button = new Button("NetworkedClient"); button.AddConstraint(Constraint.LockInPlace(button)); button.AddCallback("startnetworkedclient"); MainInterface.addButton(button); button = new Button("Interface2d"); button.AddConstraint(Constraint.LockInPlace(button)); button.AddCallback("startinterface2d"); MainInterface.addButton(button); button = new Button("Interfaceplanes"); button.AddConstraint(Constraint.LockInPlace(button)); button.AddCallback("startinterfaceplanes"); MainInterface.addButton(button); button = new Button("Interfaceplanes3d"); button.AddConstraint(Constraint.LockInPlace(button)); button.AddCallback("startinterfaceplanes3d"); MainInterface.addButton(button); // Just add the interface directly to the layout, it will assign it to the root plane. MainLayout.AddInterface(MainInterface); done = true; break; case "interface": // Update the interface(s) and get result. UserCallBack result = Controller.updateUi(MainLayout); if (result.trigger) { Log("User tapped " + result.sender + ", starting storyline " + result.label); Director.Instance.NewStoryLine(result.label); } break; default: done = true; break; } return(done); }
public bool TaskHandler(StoryTask task) { bool done = false; switch (task.Instruction) { case "makeinterface2d": // Create a controller Controller = new Controller(); // Create a layout (can hold multiple planes and interfaces) MainLayout = new Layout(); // Create an interface MainInterface = new InterFace(UserCanvas.gameObject, "demo"); // Create a mapping and add it to the interface MainMapping = new Mapping(); MainMapping.ux_single_2d += Methods.Drag2D; MainMapping.ux_tap_2d += Methods.tapButton2D; MainInterface.AddMapping(MainMapping); // Create a free moving button and add it to the interface Button button; button = new Button("Freemoving"); button.AddCallback("freemovingcallback"); MainInterface.addButton(button); // Create a free moving button and add it to the interface button = new Button("Locked"); button.AddCallback("lockedcallback"); button.AddConstraint(Constraint.LockInPlace(button)); MainInterface.addButton(button); // Create a constrained button and add it to the interface. Coordinates are local. Constraint slideConstraint = new Constraint() { hardClamp = true, hardClampMin = new Vector2(-250f, 350f), hardClampMax = new Vector2(250f, 350f), edgeSprings = true, edgeSpringMin = new Vector2(-200f, 350f), edgeSpringMax = new Vector2(200f, 350f) }; button = new Button("Slide"); button.AddConstraint(slideConstraint); MainInterface.addButton(button); // Create a button with spring positions and add it to the interface. Constraint springConstraint = new Constraint() { hardClamp = true, hardClampMin = new Vector2(-250f, 250f), hardClampMax = new Vector2(250f, 250f), springs = true, springPositions = new Vector2[] { new Vector2(-200f, 250f), new Vector2(-100f, 250f), new Vector2(0f, 250f), new Vector2(100f, 250f), new Vector2(200f, 250f) } }; button = new Button("Springs"); button.AddConstraint(springConstraint); MainInterface.addButton(button); // Create two buttons with the same drag target, so they work as a group. button = new Button("Option1", GameObject.Find("MenuFree")); MainInterface.addButton(button); button = new Button("Option2", GameObject.Find("MenuFree")); MainInterface.addButton(button); // Create a button with orthogonal dragging (so either horizontal or vertical) and add it to the interface. Constraint verticalConstraint = new Constraint() { hardClamp = true, hardClampMin = new Vector2(0f, -200f), hardClampMax = new Vector2(0f, 200f) }; Constraint horizontalConstraint = new Constraint() { hardClamp = true, hardClampMin = new Vector2(-200f, -350f), hardClampMax = new Vector2(200f, -350f) }; button = new Button("Ortho"); button.AddOrthoConstraints(GameObject.Find("Layer"), horizontalConstraint, GameObject.Find("Sublayer"), verticalConstraint); //button.AddConstraint(circleConstraint); MainInterface.addButton(button); // Create a button with circular constraint and add it to the interface. // Works from 0,0 local position Constraint circleConstraint = new Constraint() { radiusClamp = true, radiusClampMin = 100f, radiusClampMax = 100f }; button = new Button("Circle"); button.AddConstraint(circleConstraint); MainInterface.addButton(button); // Create a free moving button and add it to the interface button = new Button("Exit"); button.AddConstraint(Constraint.LockInPlace(button)); button.AddCallback("startmenu"); MainInterface.addButton(button); // Just using single plane for demo, add the interface to it MainLayout.AddInterface(MainInterface); done = true; break; case "makeinterfaceplanes": // Create a controller Controller = new Controller(); // Create a layout (can hold multiple planes and interfaces) MainLayout = new Layout(); // Create a plane Plane UpperPlane = new Plane(GameObject.Find("UpperPlane")); Plane LowerPlane = new Plane(GameObject.Find("LowerPlane")); // Create an interface UpperInterface = new InterFace(UserCanvas.gameObject, "upper"); LowerInterface = new InterFace(UserCanvas.gameObject, "lower"); // Create a mapping and add it to the interface MainMapping = new Mapping(); MainMapping.ux_single_2d += Methods.Drag2D; MainMapping.ux_tap_2d += Methods.tapButton2D; // Add together. UpperInterface.AddMapping(MainMapping); UpperPlane.AddInterface(UpperInterface); LowerInterface.AddMapping(MainMapping); LowerPlane.AddInterface(LowerInterface); // Create buttons button = new Button("Button01"); UpperInterface.addButton(button); button = new Button("Button02"); LowerInterface.addButton(button); // Create an exit button and add it to the interface button = new Button("Exit"); button.AddConstraint(Constraint.LockInPlace(button)); button.AddCallback("startmenu"); UpperInterface.addButton(button); // Add to layout. MainLayout.AddPlane(UpperPlane); MainLayout.AddPlane(LowerPlane); done = true; break; case "makeinterfaceplanes3d": // Create a controller Controller = new Controller(); // Create a layout (can hold multiple planes and interfaces) MainLayout = new Layout(); // Create a plane Plane UpperPlane3d = new Plane(GameObject.Find("UpperPlane")); Plane LowerPlane3d = new Plane(GameObject.Find("LowerPlane")); // Create an interface UpperInterface = new InterFace(UserCanvas.gameObject, "upper"); LowerInterface = new InterFace(UserCanvas.gameObject, "lower"); // Create a mapping and add it to the interface MainMapping = new Mapping(); MainMapping.ux_single_none += Methods.OrbitCamera; MainMapping.ux_double_none += Methods.LateralCamera; MainMapping.ux_double_none += Methods.LongitudinalCamera; MainMapping.ux_single_2d += Methods.Drag2D; MainMapping.ux_tap_2d += Methods.tapButton2D; // Create an orbit cam with a pitch constraint. Constraint orbitConstraint = new Constraint() { pitchClamp = true, pitchClampMin = 15f, pitchClampMax = 85f }; UiCam3D uppercam = new UiCam3D(GameObject.Find("CameraUpper")); uppercam.AddContraint(orbitConstraint); UiCam3D lowercam = new UiCam3D(GameObject.Find("CameraLower")); lowercam.AddContraint(orbitConstraint); // Create an exit button and add it to the interface button = new Button("Exit"); button.AddConstraint(Constraint.LockInPlace(button)); button.AddCallback("startmenu"); UpperInterface.addButton(button); // Add together. UpperInterface.AddUiCam3D(uppercam); LowerInterface.AddUiCam3D(lowercam); UpperInterface.AddMapping(MainMapping); LowerInterface.AddMapping(MainMapping); UpperPlane3d.AddInterface(UpperInterface); LowerPlane3d.AddInterface(LowerInterface); // Add to layout MainLayout.AddPlane(UpperPlane3d); MainLayout.AddPlane(LowerPlane3d); done = true; break; case "interface": // Update the interface(s) and get result. UserCallBack result = Controller.updateUi(MainLayout); if (result.trigger) { Log("User tapped " + result.sender + ", starting storyline " + result.label); Director.Instance.NewStoryLine(result.label); } break; case "startallsamples": SceneManager.LoadScene("AllSamples", LoadSceneMode.Single); done = true; break; default: done = true; break; } return(done); }
public bool TaskHandler(StoryTask task) { bool done = false; switch (task.Instruction) { case "makeinterface": // Create a controller Controller = new Controller(); // Create a layout (can hold multiple planes and interfaces) MainLayout = new Layout(); // Create an interface MainInterface = new InterFace(UserCanvas.gameObject, "demo"); // Create a mapping and add it to the interface MainMapping = new Mapping(); MainMapping.ux_tap_2d += Methods.tapButton2D; MainInterface.AddMapping(MainMapping); // Create an exit button and add it to the interface Button button; button = new Button("Exit"); button.AddConstraint(Constraint.LockInPlace(button)); button.AddCallback("startmenu"); MainInterface.addButton(button); // Just using single plane for demo, add the interface to it MainLayout.AddInterface(MainInterface); done = true; break; case "interface": // Update the interface(s) and get result. UserCallBack result = Controller.updateUi(MainLayout); if (result.trigger) { Log("User tapped " + result.sender + ", starting storyline " + result.label); Director.Instance.NewStoryLine(result.label); } break; case "startallsamples": SceneManager.LoadScene("AllSamples", LoadSceneMode.Single); done = true; break; case "pingpong": // Every device tries to switch the value every 5 seconds. if (Time.time > wait) { wait = Time.time + 4f; string pingpong; task.GetStringValue("debug", out pingpong); switch (pingpong) { case "ping": task.SetStringValue("debug", "pong"); Log("pong"); break; default: task.SetStringValue("debug", "ping"); Log("ping"); break; } } break; default: done = true; break; } return(done); }
public void Fight(Player A, Boss B, Mob C, Store D) //战斗 { Console.WriteLine("\t\t\t *************Boss战*************\n"); InterFace M = new InterFace(); Random r = new Random(); int a, flag = 0; int c = 1; while (c != 0) { if (HP <= 0) { Console.WriteLine("\t\t\t恭喜!你打败了食人花!{0}成功升了20级", A.Getname()); A.ChangeLevel(20); Console.WriteLine("\t\t\t即将退出Boss战"); Thread.Sleep(1500); HP = 120;//恢复血量 break; } if (A.ChangeHP(0) <= 0) { Console.WriteLine("\t\t\t你已死亡,即将退出Boss战...."); Thread.Sleep(1500); A.ChangeHP(100);//恢复血量 HP = 120; break; } a = r.Next(1, 30); if (a < 10) { Console.WriteLine("\t\t\t食人花发动了百花齐放功能,小心!"); Console.WriteLine("\t\t\t{0}被花击中,受到了20点伤害", A.Getname()); A.ChangeHP(-20); flag = 1;//用来记录游戏发生的事件; } if (a >= 10 && a < 20) { Console.WriteLine("\t\t\t食人花休眠中,这是攻击的好机会!"); flag = 2; } if (a >= 20 && a < 30) { Console.WriteLine("\t\t\t食人花发动了迷惑技能,{0}晕了过去\n\t\t\t受到了20点伤害", A.Getname()); A.ChangeHP(-20); flag = 3; } Console.Write("\n\t\t\t按1攻击,按2切换装备,按3查看技能,按4查看状态,按5使用技能,按0退出:"); c = Convert.ToInt32(Console.ReadLine()); if (c == 1) { if (A.GetWeapon() == "木剑" || A.GetWeapon() == "拳击手套") { HP -= 5; Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("\n\t\t\t{0}使用了{1}对食人花造成了5点伤害\n", A.Getname(), A.GetWeapon()); Console.ForegroundColor = ConsoleColor.White; } if (A.GetWeapon() == "弓箭" || A.GetWeapon() == "大刀") { HP -= 10; Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("\n\t\t\t{0}使用了{1}对食人花造成了10点伤害\n", A.Getname(), A.GetWeapon()); Console.ForegroundColor = ConsoleColor.White; } if (A.GetWeapon() == "长剑") { HP -= 20; Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("\n\t\t\t{0}使用了{1}对食人花造成了20点伤害\n", A.Getname(), A.GetWeapon()); Console.ForegroundColor = ConsoleColor.White ; } } if (c == 2) { Console.Clear(); M.RoleEquipment(A, B, C, D); } if (c == 3) { Console.Clear(); M.RoleSkill(A, B, C, D); } if (c == 4) { Console.Clear(); M.RoleCondition(A, B, C, D); } if (c == 5) { if (A.GetSki() == "火焰" || A.GetSki() == "凝固" || A.GetSki() == "瞬间移动") { HP -= 5; A.ChangeMP(-5);//消耗魔法值5 Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("\n\t\t\t{0}使用了{1}对食人花造成了5点伤害\n", A.Getname(), A.GetSki()); Console.ForegroundColor = ConsoleColor.White; } if (A.GetSki() == "霹雳斩" || A.GetSki() == "万箭齐发") { HP -= 10; A.ChangeMP(-10);//消耗魔法值10 Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("\n\t\t\t{0}使用了{1}对食人花造成了10点伤害\n", A.Getname(), A.GetSki()); Console.ForegroundColor = ConsoleColor.White; } if (A.GetSki() == "五项全能") { HP -= 20; A.ChangeMP(-10);//消耗魔法值10 Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("\n\t\t\t{0}使用了{1}对食人花造成了20点伤害\n", A.Getname(), A.GetSki()); Console.ForegroundColor = ConsoleColor.White; } } } Console.Clear(); M.MainFace(A, B, C, D); }
public Controler(ModelS model, InterFace view) { this.model = model; this.view = view; }
void Awake() { // m_gyrogameupdate = Camera.main.GetComponent<GyroGameUpdate>(); interFace = GameObject.Find("InterFace").GetComponent <InterFace>(); }