protected override AbstractBehaviour InitScript() { // if (RingPhone != null) // AudioSource.PlayClipAtPoint (RingPhone,phone.transform.position); PhoneDevice phoneDevice = phone.GetComponent <PhoneDevice>(); phoneDevice.Ring(); this.BName = "AnswerThePhone"; AbstractBehaviour[] behaviours = new AbstractBehaviour[2]; GoToBehaviour behaviour = gameObject.AddComponent(typeof(GoToBehaviour)) as GoToBehaviour; behaviour.avatarRigidbody = playerRigidbody; behaviour.roomToGo = "Phone"; behaviour.aStarGameObject = aStar; // behaviour.PathInit (); behaviour.BName = "Move"; behaviours [0] = behaviour; UseDeviceBehaviour uDBehaviour = gameObject.AddComponent(typeof(UseDeviceBehaviour)) as UseDeviceBehaviour; uDBehaviour.DeviceToUse = phone; uDBehaviour.BName = "Answer"; behaviours [1] = uDBehaviour; // this.Behaviours = behaviours; Sequence sequence = gameObject.AddComponent(typeof(Sequence)) as Sequence; sequence.Behaviours = behaviours; return(sequence); }
protected override AbstractBehaviour InitScript() { this.BName = "Call for bus"; AbstractBehaviour[] behaviours = new AbstractBehaviour[2]; GoToBehaviour behaviour = gameObject.AddComponent(typeof(GoToBehaviour)) as GoToBehaviour; behaviour.avatarRigidbody = playerRigidbody; behaviour.roomToGo = "Phone"; behaviour.aStarGameObject = aStar; // behaviour.PathInit (); behaviour.BName = "Move"; behaviours [0] = behaviour; UseDeviceBehaviour uDBehaviour = gameObject.AddComponent(typeof(UseDeviceBehaviour)) as UseDeviceBehaviour; uDBehaviour.DeviceToUse = phone; uDBehaviour.BName = "Call"; behaviours [1] = uDBehaviour; // this.Behaviours = behaviours; Sequence sequence = gameObject.AddComponent(typeof(Sequence)) as Sequence; sequence.Behaviours = behaviours; return(sequence); }
public void RemoveBehaviour(AbstractBehaviour behav) { AbstractBehaviour beh = SomethingInTheWorld.Find(a => a.BehaviourID == behav.BehaviourID); lock (SomethingInTheWorld) SomethingInTheWorld.Remove(beh); beh.Dispose(); }
public void AddBehaviour(AbstractBehaviour beh) { beh.Belongs = this; beh.Initialize(); lock (SomethingInTheWorld) SomethingInTheWorld.Add(beh); BehaviourController.StartUpdateBehaviour(beh); }
public DefaultMooshroom(int x, AbstractBehaviour _behaviour, bool _inRain, Rufus _rufus) { rufus = _rufus; inRain = _inRain; position.X = x; behaviour = _behaviour; range = 35; }
protected override AbstractBehaviour InitScript() { this.BName = "Clean bathroom"; if (smartHomeServer != null) { SensorsGUI gui = smartHomeServer.GetComponent <SensorsGUI> (); gui.SetDebugText(9, BName); gui.BehaviourTreeToShow = this; } AbstractBehaviour[] behaviours = new AbstractBehaviour[5]; GoToBehaviour behaviour = gameObject.AddComponent(typeof(GoToBehaviour)) as GoToBehaviour; behaviour.avatarRigidbody = playerRigidbody; behaviour.roomToGo = "Bathroom"; behaviour.aStarGameObject = aStar; // behaviour.PathInit (); behaviour.BName = "Move"; behaviours [0] = behaviour; behaviour = gameObject.AddComponent(typeof(GoToBehaviour)) as GoToBehaviour; behaviour.avatarRigidbody = playerRigidbody; behaviour.roomToGo = "WC"; behaviour.aStarGameObject = aStar; // behaviour.PathInit (); behaviour.BName = "Moveto WC"; behaviours [1] = behaviour; UseDeviceBehaviour uDBehaviour = gameObject.AddComponent(typeof(UseDeviceBehaviour)) as UseDeviceBehaviour; uDBehaviour.DeviceToUse = toilet; uDBehaviour.BName = "WC use"; behaviours [2] = uDBehaviour; behaviour = gameObject.AddComponent(typeof(GoToBehaviour)) as GoToBehaviour; behaviour.avatarRigidbody = playerRigidbody; behaviour.roomToGo = "Washbasin"; behaviour.aStarGameObject = aStar; // behaviour.PathInit (); behaviour.BName = "Moveto ashbasin"; behaviours [3] = behaviour; AtomicActivityBehaviour aABehaviour = gameObject.AddComponent(typeof(AtomicActivityBehaviour)) as AtomicActivityBehaviour; aABehaviour.duration = duration; aABehaviour.BName = "Clean"; behaviours [4] = aABehaviour; // this.Behaviours = behaviours; Sequence sequence = gameObject.AddComponent(typeof(Sequence)) as Sequence; sequence.Behaviours = behaviours; return(sequence); }
public RufusModel(string _thumbPath, string _largePath, bool _isActive, AbstractBehaviour _behaviour, int _price, string _title, string _description) { thumbPath = _thumbPath; largePath = _largePath; behaviour = _behaviour; isActive = _isActive; price = _price; title = _title; description = _description; }
public override void init(ContentManager Content) { emitter.init(Content); content = Content; screenFX.init(content); behaviour = GameModel.rufusModels.ElementAt(GameModel.currentRufusID).behaviour; // behaviour = new SuperRufusBehaviour(); spriteSheetPosition = new Vector2(); texture = Content.Load <Texture2D>(behaviour.tileSheet); spriteSheetPositions = Content.Load <Dictionary <string, Rectangle> >(behaviour.tileSheetXML); spriteSheet = new SpriteSheet(texture, spriteSheetPositions); spriteSheet.addAnimation(new AnimationStruct(AnimationStruct.IDLE, behaviour.idleFrames, 15, null)); spriteSheet.addAnimation(new AnimationStruct(AnimationStruct.JUMP, behaviour.jumpFrames, 8, endJump)); spriteSheet.addAnimation(new AnimationStruct(AnimationStruct.FALLING, behaviour.fallingFrames, 10, playIdle)); spriteSheet.addAnimation(new AnimationStruct(AnimationStruct.DOWN, behaviour.downFrames, 10, playIdle)); spriteSheet.addAnimation(new AnimationStruct(AnimationStruct.UP, behaviour.upFrames, 10, endJump)); spriteSheet.addAnimation(new AnimationStruct(AnimationStruct.AIRDYING, behaviour.airdyingFrames, 10, null)); spriteSheet.addAnimation(new AnimationStruct(AnimationStruct.DIE, behaviour.dieFrames, 8, die, false)); spriteSheet.play(AnimationStruct.IDLE); if (behaviour.centerPosition == null) { centerPosition = new Vector2(spriteSheet[spriteSheet.currentAnimation.frames.ElementAt(0)].Width / 2, spriteSheet[spriteSheet.currentAnimation.frames.ElementAt(0)].Height / 2); } else { centerPosition = behaviour.centerPosition; } spriteSheetPosition = behaviour.spriteSheetPosition; limitBaseY = 330; levelBehaviour = GameModel.levelsModels.ElementAt(GameModel.currentLevelID).behaviour; gravity = (behaviour.gravity + levelBehaviour.gravity) / 2; range = behaviour.range; force = behaviour.force; bounce = behaviour.bounce; ableToJump = true; fallings = -1; combo = 0; isInitialized = true; airDying = false; levelPoints = 0; maxMushComboCounter = 20f; mushComboCounter = 0f; isInvencible = false; mushrooms = 0; bloobs = 0; specials = 0; maxCombo = 0; maxJumps = 0; }
public static void StartUpdateBehaviour(AbstractBehaviour beh) { Thread thr = new Thread(() => { while (!beh.Terminate) { beh.Update(); Thread.Sleep(50); } }); lock (BehaviourThreads) BehaviourThreads.Add(beh, thr); thr.Start(); }
// Use this for initialization void Start() { showHelp = false; showElectricityData = false; showElectricityChartPhase1 = false; showElectricityChartPhase2 = false; showElectricityChartPhase3 = false; showDebugText = false; showBehaviourTree = true; debugText = new string[10]; showFPS = false; deltaTime = 0.0f; behaviourTreeToShow = null; electricityLogger = GetComponent <ElectricityLogger> (); }
protected override AbstractBehaviour InitScript() { this.BName = "Put Stuff Into Ward Robe"; AbstractBehaviour[] behaviours = new AbstractBehaviour[4]; GoToBehaviour behaviour = gameObject.AddComponent(typeof(GoToBehaviour)) as GoToBehaviour; behaviour.avatarRigidbody = playerRigidbody; behaviour.roomToGo = "Entrance"; behaviour.aStarGameObject = aStar; // behaviour.PathInit (); behaviour.BName = "Move"; behaviours [0] = behaviour; behaviour = gameObject.AddComponent(typeof(GoToBehaviour)) as GoToBehaviour; behaviour.avatarRigidbody = playerRigidbody; behaviour.roomToGo = "Wardrobe"; behaviour.aStarGameObject = aStar; // behaviour.PathInit (); behaviour.BName = "Move"; behaviours [1] = behaviour; AtomicActivityBehaviour aABehaviour = gameObject.AddComponent(typeof(AtomicActivityBehaviour)) as AtomicActivityBehaviour; aABehaviour.duration = duration; aABehaviour.BName = "Clean"; behaviours [2] = aABehaviour; behaviour = gameObject.AddComponent(typeof(GoToBehaviour)) as GoToBehaviour; behaviour.avatarRigidbody = playerRigidbody; behaviour.roomToGo = "Livingroom"; behaviour.aStarGameObject = aStar; // behaviour.PathInit (); behaviour.BName = "Move"; behaviours [3] = behaviour; // this.Behaviours = behaviours; Sequence sequence = gameObject.AddComponent(typeof(Sequence)) as Sequence; sequence.Behaviours = behaviours; return(sequence); }
private void ShowBehaviourTree(int x, int y, int witdh, int heigth) { if (behaviourTreeToShow != null) { GUI.Box(new Rect(x, y, witdh, heigth), "Activity Tree"); AbstractBehaviour current = behaviourTreeToShow; int deltaX = 8; int deltaY = 16; string indent = ""; while (current != null) { GUI.Label(new Rect(x + deltaX, y + deltaY, witdh - 32, 24), indent + current.BName); if (current is Sequence) { List <AbstractBehaviour> sub = ((Sequence)current).GetActiveBehaviours(); if (sub.Count == 1) { current = sub [0]; indent += "-"; deltaY += 24; } else { current = null; } } else if (current is AbstractScript) { current = ((AbstractScript)current).Behaviour; indent += "-"; deltaY += 24; } else { current = null; } } } }
protected override AbstractBehaviour InitScript() { this.BName = "Scenario1"; AbstractBehaviour[] behaviours = new AbstractBehaviour[3]; GoToBehaviour behaviour = gameObject.AddComponent(typeof(GoToBehaviour)) as GoToBehaviour; behaviour.avatarRigidbody = playerRigidbody; behaviour.roomToGo = roomToGo1; behaviour.aStarGameObject = aStar; // behaviour.PathInit (); behaviour.BName = "Move1"; behaviours [0] = behaviour; behaviour = gameObject.AddComponent(typeof(GoToBehaviour)) as GoToBehaviour; behaviour.avatarRigidbody = playerRigidbody; behaviour.roomToGo = roomToGo2; behaviour.aStarGameObject = aStar; // behaviour.PathInit (); behaviour.BName = "Move2"; behaviours [1] = behaviour; UseDeviceBehaviour uDBehaviour = gameObject.AddComponent(typeof(UseDeviceBehaviour)) as UseDeviceBehaviour; uDBehaviour.DeviceToUse = deviceToUse; uDBehaviour.BName = "Act"; behaviours [2] = uDBehaviour; // this.Behaviours = behaviours; Sequence sequence = gameObject.AddComponent(typeof(Sequence)) as Sequence; sequence.Behaviours = behaviours; return(sequence); // this.Run (); }
public override void Init() { behaviour = InitScript(); }
// Start is called before the first frame update void Start() { behaviour = GetComponent <AbstractBehaviour>(); }
protected override AbstractBehaviour InitScript() { this.BName = "Make a dish"; if (smartHomeServer != null) { SensorsGUI gui = smartHomeServer.GetComponent <SensorsGUI> (); gui.SetDebugText(9, BName); gui.BehaviourTreeToShow = this; } AbstractBehaviour[] behaviours = new AbstractBehaviour[68]; behaviours[0] = CreateGoToBehaviour("Kitchen"); behaviours[1] = CreateGoToBehaviour("KitchenDishes"); behaviours[2] = CreateTakeItemBehaviour(mug); behaviours[3] = CreateGoToBehaviour("KitchenDevices"); behaviours[4] = CreatePutItemAtBehaviour(mug, 10.31f, 10.54f, 84.84f); behaviours[5] = CreateUseDeviceBehaviour(coffeeMachine); behaviours[6] = CreateGoToBehaviour("KitchenTools"); behaviours[7] = CreateTakeItemBehaviour(frypan); behaviours[8] = CreateGoToBehaviour("Cooker"); behaviours[9] = CreatePutItemAtBehaviour(frypan, 38.94f, 16.01f, 105.15f); behaviours[10] = CreateUseDeviceBehaviour(cooker); behaviours[11] = CreateGoToBehaviour("Refrigerator"); behaviours[12] = CreateAtomicActivityBehaviour("Take Eggs", 5f); behaviours[13] = CreateGoToBehaviour("Cooker"); behaviours[14] = CreateAtomicActivityBehaviour("Cook Eggs", 5f); behaviours[15] = CreateUseDeviceBehaviour(cooker); behaviours[16] = CreateGoToBehaviour("KitchenDishes"); behaviours[17] = CreateTakeItemBehaviour(dish); behaviours[18] = CreateGoToBehaviour("Cooker"); behaviours[19] = CreatePutItemAtBehaviour(dish, 35.476f, 9.867f, 111.679f); behaviours[20] = CreateTakeItemBehaviour(frypan); behaviours[21] = CreateAtomicActivityBehaviour("Put Eggs into dish", 4f); behaviours[22] = CreateGoToBehaviour("KitchenSink"); behaviours[23] = CreatePutItemAtBehaviour(frypan, 40.369f, 7.46f, 93.18f); behaviours[24] = CreateGoToBehaviour("Cooker"); behaviours[25] = CreateTakeItemBehaviour(dish); behaviours[26] = CreateGoToBehaviour("KitchenDishes"); behaviours[27] = CreateTakeItemBehaviour(fork); behaviours[28] = CreateGoToBehaviour("KitchenDevices"); behaviours[29] = CreateAtomicActivityBehaviour("Take toast", 4f); behaviours[30] = CreateGoToBehaviour("DiningTable"); behaviours[31] = CreatePutItemAtBehaviour(dish, 25.1f, 11.41f, 40.4f); behaviours[32] = CreatePutItemAtBehaviour(fork, 21.32f, 11.41f, 40.4f); behaviours[33] = CreateGoToBehaviour("KitchenDevices"); behaviours[34] = CreateTakeItemBehaviour(mug); behaviours[35] = CreateAtomicActivityBehaviour("Take sugar", 4f); behaviours[36] = CreateGoToBehaviour("DiningTable"); behaviours[37] = CreatePutItemAtBehaviour(mug, 24.89f, 11.41f, 34.7f); behaviours[38] = CreateAtomicActivityBehaviour("Watch food", 4f); behaviours[39] = CreateTakeItemBehaviour(fork); behaviours[40] = CreateTakeItemBehaviour(dish); behaviours[41] = CreateGoToBehaviour("KitchenSink"); behaviours[42] = CreateUseDeviceBehaviour(sink); behaviours[43] = CreatePutItemAtBehaviour(dish, 40.369f, 7.46f, 93.18f); behaviours[44] = CreatePutItemAtBehaviour(fork, 40.369f, 7.46f, 93.18f); behaviours[45] = CreateAtomicActivityBehaviour("Do the washing up", 10f); behaviours[46] = CreateTakeItemBehaviour(fork); behaviours[47] = CreatePutItemAtBehaviour(fork, 38.41f, 10.54f, 97.75f); behaviours[48] = CreateTakeItemBehaviour(dish); behaviours[49] = CreatePutItemAtBehaviour(dish, 36.91f, 10.54f, 97.75f); behaviours[50] = CreateAtomicActivityBehaviour("Wash the frypan", 10f); behaviours[51] = CreateTakeItemBehaviour(frypan); behaviours[52] = CreateUseDeviceBehaviour(sink); behaviours[53] = CreateGoToBehaviour("KitchenTools"); behaviours[54] = CreatePutItemAtBehaviour(frypan, 41.21f, 19.2f, 84.06f); behaviours[55] = CreateGoToBehaviour("KitchenSink"); behaviours[56] = CreateGoToBehaviour("DiningTable"); behaviours[57] = CreateTakeItemBehaviour(mug); behaviours[58] = CreateGoToBehaviour("KitchenSink"); behaviours[59] = CreateUseDeviceBehaviour(sink); behaviours[60] = CreateAtomicActivityBehaviour("Wash the mug", 4f); behaviours[61] = CreateUseDeviceBehaviour(sink); behaviours[62] = CreateTakeItemBehaviour(dish); behaviours[63] = CreateTakeItemBehaviour(fork); behaviours[64] = CreateGoToBehaviour("KitchenDishes"); behaviours[65] = CreatePutItemAtBehaviour(fork, 19.37021f, 8.851f, 120.51f); behaviours[66] = CreatePutItemAtBehaviour(dish, 22.46242f, 9.782906f, 120.6399f); behaviours[67] = CreatePutItemAtBehaviour(mug, 15.15f, 8.83f, 120.31f); // behaviours[31] = CreateGoToBehaviour("KitchenDishes"); // behaviours[31] = CreatePutItemAtBehaviour(mug, 22.95f, 11.41f, 37.9f); Sequence sequence = gameObject.AddComponent(typeof(Sequence)) as Sequence; sequence.Behaviours = behaviours; return(sequence); }
internal void update(GameTime gameTime) { timer += (float)gameTime.ElapsedGameTime.TotalSeconds; if (timer >= timecounter) { Shuffle(lineID); Shuffle(colID); DefaultEntity temp; Random rndn = new Random(DateTime.Now.Millisecond); int acum = 0; AbstractBehaviour levelBehaviour = GameModel.levelsModels.ElementAt(GameModel.currentLevelID).behaviour; for (int i = 0; i < 5; i++) { float rnd = rndn.Next(0, 35); acumSpecial--; if (acumSpecial <= 0) { temp = null; RufusModel tempModel = GameModel.getStarByFrequency(); if (tempModel != null) { if (tempModel.behaviour is SimpleStarBehaviour) { temp = new Star(10); temp.position.X = colID[acum] * 80; temp.position.Y = lineID[acum] * 60; } else if (tempModel.behaviour is MagneticStarBehaviour || tempModel.behaviour is RainStarBehaviour || tempModel.behaviour is TimeStarBehaviour) { temp = new DefaultMooshroom(0, tempModel.behaviour, false, rufus); temp.position.X = colID[acum] * 80; temp.position.Y = lineID[acum] * 60; } } acumSpecial = (int)(10 + rndn.NextDouble() * 40); } else if (rnd < 4 + levelBehaviour.frequency) { LevelBehaviour tempBehaviour = levelBehaviour as LevelBehaviour; if (tempBehaviour.enemy == 1) { temp = new Bomb1(colID[acum] * 80, (int)((float)rndn.NextDouble() * 30 - 30f)); } else if (tempBehaviour.enemy == 2) { temp = new BerryBomb(colID[acum] * 80, (int)((float)rndn.NextDouble() * 30 - 30f)); } else if (tempBehaviour.enemy == 3) { temp = new JackO(colID[acum] * 80, (int)((float)rndn.NextDouble() * 30 - 30f)); } else if (tempBehaviour.enemy == 4) { temp = new Hells(colID[acum] * 80, (int)((float)rndn.NextDouble() * 30 - 30f)); } else if (tempBehaviour.enemy == 5) { temp = new CloudEye(colID[acum] * 80, (int)((float)rndn.NextDouble() * 30 - 30f)); } else if (tempBehaviour.enemy == 6) { temp = new Goomba(colID[acum] * 80, (int)((float)rndn.NextDouble() * 30 - 30f)); } else { temp = new Bomb1(colID[acum] * 80, (int)((float)rndn.NextDouble() * 30 - 30f)); } temp.position.Y = -60; } else if (rnd < 7 + levelBehaviour.frequency) { RufusModel tempModel = GameModel.getBolinhaByFrequency(); if (tempModel != null) { if (tempModel.behaviour is GreenBolinhaBehaviour) { temp = new Bolinha(colID[acum] * 80); temp.position.Y = -50; } else if (tempModel.behaviour is RedBolinhaBehaviour) { temp = new BolinhaVermelha(colID[acum] * 80); } else if (tempModel.behaviour is JumpBolinhaBehaviour) { temp = new BolinhaPulante(colID[acum] * 80); } else { temp = new BolinhaQuicante(colID[acum] * 80); temp.position.Y = -50; } } else { temp = null; } } //else if (rnd < 8 + levelBehaviour.frequency) //{ // temp = null; // RufusModel tempModel = GameModel.getStarByFrequency(); // if (tempModel != null) // { // if (tempModel.behaviour is SimpleStarBehaviour) // { // temp = new Star(10); // temp.position.X = colID[acum] * 80; // temp.position.Y = lineID[acum] * 60; // } // else if (tempModel.behaviour is MagneticStarBehaviour || tempModel.behaviour is RainStarBehaviour || tempModel.behaviour is TimeStarBehaviour) // { // temp = new DefaultMooshroom(0, tempModel.behaviour, false, rufus); // temp.position.X = colID[acum] * 80; // temp.position.Y = lineID[acum] * 60; // } // } //} else { // temp = new DefaultMooshroom(0, GameModel.itensModels.ElementAt(1).behaviour); temp = new DefaultMooshroom(0, GameModel.getMushroomByFrequency().behaviour, false, rufus); temp.position.X = colID[acum] * 80; temp.position.Y = lineID[acum] * 60; } if (temp != null) { entityLayer.add(temp); entityLayer.init(content); } timer = 0f; acum++; } } }
private void Start() { SetCurrentSpeedToMaxSpeed(); behaviour = GetComponent <AbstractBehaviour>(); }