public override Unit CreateUnit(IArmy army) { var fireMan = new FireMan { Army = army, Hit = 20, Health = 80, Weapons = 5 }; return(fireMan); }
public void SetFiremanStartingSpace(FireMan f, Cell startingCell) { if (startingCell.GetKind() == CellKind.OUTDOOR) { f.SetLocation(startingCell); //we have both because the event version is sent to all clients except this one IncrementTurn(); EventManager.i.IncrementTurnEvent(); } }
public void TestShortestPath(FireMan fireman) { //fireman.SetAP(100); Vector2 start = new Vector2(4, 0); Vector2 end = new Vector2(0, 0); Cell startCell = cells[start]; Cell endCell = cells[end]; int cost; List <Cell> path = fireman.GetCheapestPath(startCell, endCell, out cost); DrawShortestPath(path); }
public void LoadContentAndCreateScenes(GraphicsDeviceManager graphics, ContentManager Content) { // Scene number 0 Scene scene0 = new Scene(); BackGround building = new BackGround(); building.AddTexture(Content.Load <Texture2D>("protoBuilding.png")); building.position = new Vector2(480 / 2, 480); scene0.AddGameObject(building); FireMan fireMan; fireMan = new FireMan(graphics); fireMan.AddAnimation(new Animation(Content.Load <Texture2D>("FiremanFlyRightAnimation.png"), new Vector2(100, 100), 5)); fireMan.AddAnimation(new Animation(Content.Load <Texture2D>("FiremanFlyLeftAnimation.png"), new Vector2(100, 100), 5)); //fireMan.AddAnimation(new Animation(Content.Load<Texture2D>("MarkRight.png"), new Vector2(100, 100), 5)); //fireMan.AddAnimation(new Animation(Content.Load<Texture2D>("MarkLeft.png"), new Vector2(100, 100), 5)); fireMan.AddTexture(Content.Load <Texture2D>("FiremanAttackRight.png")); fireMan.AddTexture(Content.Load <Texture2D>("FiremanAttackLeft.png")); //fireMan.AddTexture(Content.Load<Texture2D>("MarkRightAttack.png")); //fireMan.AddTexture(Content.Load<Texture2D>("MarkLeftAttack.png")); WaterParticlesController particleController = new WaterParticlesController(40); particleController.AddTexture(Content.Load <Texture2D>("Drop.png")); fireMan.AddParticleController(particleController); scene0.AddGameObject(fireMan); Trampoline trampoline; trampoline = new Trampoline(graphics); trampoline.AddAnimation(new Animation(Content.Load <Texture2D>("TwoWithTrampolineAnimation.png"), new Vector2(150, 100), 10)); trampoline.AddTexture(Content.Load <Texture2D>("TwoWithTrampoline1.png")); fireMan.trampoline = trampoline; scene0.AddGameObject(trampoline); this.AddScene(scene0); currentSceneNumber = 0; }
public void MakePopupPanel() { if (!game.IsLocalPlayersTurn()) { return; } PopupManager popup = PopupManager.Instance; //This is going off the assumption that we currently only have one player at a time FireMan fireman = game.GetLocalFireman(); if (GetStatus() == DoorStatus.OPEN) { int cost = fireman.determineCost(ActionType.TOGGLE_DOOR); string msg = string.Format("Close Door: {0} AP", cost); popup.AddButton(msg, delegate { fireman.ToggleDoor(this); }); } else if (GetStatus() == DoorStatus.CLOSED) { int cost = fireman.determineCost(ActionType.TOGGLE_DOOR); string msg = string.Format("Open Door: {0} AP", cost); popup.AddButton(msg, delegate { fireman.ToggleDoor(this); }); } Vector2 position = gameObject.GetComponent <RectTransform>().anchoredPosition; //bad Sarah Vector3 rotation = gameObject.GetComponent <RectTransform>().rotation.eulerAngles; //if the edge is vertical, offset the popup by less if (rotation.Equals(Vector3.zero)) { position.x += 160; } else { position.x += 320; } popup.SetPositionAndShow(position); }
public void OnEvent(EventData photonEvent) { byte eventCode = photonEvent.Code; object[] data = null; Cell cell = null; int viewId = -1; switch (eventCode) { case GameEvents.IncrementTurn: Game.Instance.IncrementTurn(); if (Game.Instance.IsLocalPlayersTurn()) { Player player = Game.Instance.GetCurrentPlayer(); foreach (POI poi in Game.Instance.activePOIs) { ((MonoBehaviourPun)poi).photonView.TransferOwnership(player.ActorNumber); } } break; case GameEvents.FindFiremanAndAssociate: //first arg is player's ActorNumber //second arg is fireman GameObject's viewID data = (object[])photonEvent.CustomData; int actorNumber = (int)data[0]; viewId = (int)data[1]; GameObject firemanGo = PhotonView.Find(viewId).gameObject; FireMan fireman = firemanGo.GetComponent <FireMan>(); Game.Instance.AddFiremanAndAssociate(fireman, actorNumber); break; case GameEvents.SetCellStatus: data = (object[])photonEvent.CustomData; Game.Instance.GetCell((int)data[0], (int)data[1], ref cell); CellStatus status = (CellStatus)data[2]; cell.SetStatus(status); break; case GameEvents.DamageWall: data = (object[])photonEvent.CustomData; Game.Instance.GetCell((int)data[0], (int)data[1], ref cell); Wall wall = (Wall)cell.GetEdge((Direction)data[2]); wall.Damage(); break; case GameEvents.SetDoorStatus: data = (object[])photonEvent.CustomData; Game.Instance.GetCell((int)data[0], (int)data[1], ref cell); Door door = (Door)cell.GetEdge((Direction)data[2]); door.SetStatus((DoorStatus)data[3]); break; case GameEvents.FindPOI: data = (object[])photonEvent.CustomData; viewId = (int)data[0]; GameObject poiGo = PhotonView.Find(viewId).gameObject; if (poiGo.GetComponent <Victim>() != null) { Game.Instance.inactivePOIs.Add(poiGo.GetComponent <Victim>()); } else { Game.Instance.inactivePOIs.Add(poiGo.GetComponent <FalseAlarm>()); } break; case GameEvents.ActivatePOIEvent: data = (object[])photonEvent.CustomData; int index = (int)data[0]; if (index > Game.Instance.inactivePOIs.Count) { Debug.LogError("it seems that the inactivePOIs arraylist is out of sync"); index = 0; } Game.Instance.GetCell((int)data[1], (int)data[2], ref cell); Game.Instance.ActivatePOI(index, cell); break; case GameEvents.TransferOwnership: break; default: Debug.Log("event code not implemented: " + eventCode); break; } }
IEnumerator RestOfStart() { //waits until the BoardLoader has finished instantiating cells yield return(new WaitUntil(() => cells.Count == 80)); int i, j; //Initializing all of the Fire Men and storing them Vector3 initialPosition = new Vector3(-102, 910, 0); i = 1; if (PhotonNetwork.IsMasterClient) { foreach (Player player in players) { //Associating the players to specific FireMen (This step will have to be modified when we add the "choose who's what color in the gameLobby") GameObject firemanGo = PhotonNetwork.Instantiate("FireFighter" + i, initialPosition, Quaternion.identity); firemanGo.GetPhotonView().TransferOwnership(player.ActorNumber); FireMan fireman = firemanGo.GetComponent <FireMan>(); AddFiremanAndAssociate(fireman, player.ActorNumber); //inform the other clients of how to associate fireman EventManager.i.FindFiremanAndAssociateEvent(firemanGo, player); i++; } //Instantiate the vicims. Randomization will occur when we take from it for (i = 0; i < 10; i++) { Victim newVictim = PhotonNetwork.Instantiate("Victim", Vector3.zero, Quaternion.identity).GetComponent <Victim>(); inactivePOIs.Add(newVictim); EventManager.i.FindPOI(newVictim); } //Instantiate the falseAlarms for (i = 0; i < 5; i++) { FalseAlarm newFa = PhotonNetwork.Instantiate("FalseAlarm", Vector3.zero, Quaternion.identity).GetComponent <FalseAlarm>(); inactivePOIs.Add(newFa); EventManager.i.FindPOI(newFa); } //THIS IS WHERE WE WILL WANT TO ADD ALL OF THE STARTING FIRES AND POIs Vector2[] coords = { new Vector2(2, 2), new Vector2(3, 2), new Vector2(2, 3), new Vector2(3, 3), new Vector2(4, 3), new Vector2(5, 3), new Vector2(4, 4), new Vector2(6, 5), new Vector2(7, 5), new Vector2(6, 6), new Vector2(4, 2), new Vector2(1, 5), new Vector2(8, 5) }; for (i = 0; i < 10; i++) { Cell cell = null; cells.TryGetValue(coords[i], out cell); EventManager.i.SetCellStatusEvent(cell, CellStatus.FIRE); } for (i = i; i < 13; i++) { int randomizer = rand.Next(0, inactivePOIs.Count); Cell cell = null; cells.TryGetValue(coords[i], out cell); ActivatePOI(randomizer, cell); EventManager.i.ActivatePOIEvent(randomizer, cell); } } topPanel = GameObject.Find("TopPanel"); topPanelTransform = topPanel.GetComponent <RectTransform>(); UpdateText(); playerTurn = 0; }
//Adds a FireMan.cs object to the list of firemen and associate it with the //given actor number public void AddFiremanAndAssociate(FireMan fireman, int actorNumber) { fireMen.Add(fireman); playerToFireman.Add(actorNumber, fireman); }
public void MakePopupPanel() { if (!game.IsLocalPlayersTurn()) { return; } PopupManager popup = PopupManager.Instance; Vector2 position = GetTransform().anchoredPosition; position.x += 160 + 150; position.y += 840 + 10; //This is going off the assumption that we currently only have one player at a time FireMan fireman = game.GetLocalFireman(); if (fireman == null) { Debug.Log("fireman is null!"); } if (game.status == GameStatus.MAIN_GAME) { foreach (POI poi in pois) { if (poi.GetStatus() == POIstatus.REVEALED && typeof(Victim).IsInstanceOfType(poi) && fireman.GetVictim() == null && fireman.GetLocation() == this) { popup.AddButton("Pickup Victim: 0 AP", delegate { fireman.Pickup((Victim)pois[0]); }); } } if (fireman.GetVictim() != null && fireman.GetLocation() == this) { popup.AddButton("Drop Victim: 0 AP", delegate { fireman.Drop(); }); } if (this.status == CellStatus.FIRE) { int cost1 = fireman.determineCost(ActionType.EXTINGUISH); string msg1 = string.Format("Putout Fire: {0} AP", cost1); popup.AddButton(msg1, delegate { fireman.ExtinguishFire(this); }); } else { int cost = game.PathFinder(this); string msg = string.Format("Move: {0} AP", cost); popup.AddButton(msg, delegate { fireman.Move(this); }); } if (this.status == CellStatus.SMOKE) { int cost1 = fireman.determineCost(ActionType.EXTINGUISH); string msg1 = string.Format("Putout Smoke: {0} AP", cost1); popup.AddButton(msg1, delegate { fireman.ExtinguishFire(this); }); } popup.SetPositionAndShow(position); } else if (game.status == GameStatus.SETUP) { if (this.kind == CellKind.OUTDOOR) { popup.AddButton("Select Starting Space", delegate { game.SetFiremanStartingSpace(fireman, this); }); popup.SetPositionAndShow(position); } else { Debug.Log("Please pick an outdoor cell"); } } }