public static bool DeletePit(Pit pit) { // create and open a connection NpgsqlConnection conn = DatabaseConnection.GetConnection(); conn.Open(); // Define a query string query = "DELETE FROM pits WHERE \"intPitID\" = @intPitID "; NpgsqlCommand cmd = new NpgsqlCommand(query, conn); cmd.Parameters.AddWithValue("intPitID", pit.IntPitID); // Execute a query int result = cmd.ExecuteNonQuery(); conn.Close(); if (result == 1) { return(true); } else { return(false); } }
private void Start() { pit = GetComponentInParent <Pit>(); standingPosition = transform.position; rdbd = GetComponent <Rigidbody>(); }
public static IEnumerable <Pit> GetAllPits() { List <Pit> retval = new List <Pit>(); // create and open a connection NpgsqlConnection conn = DatabaseConnection.GetConnection(); conn.Open(); // Define a query string query = "SELECT * FROM pits"; NpgsqlCommand cmd = new NpgsqlCommand(query, conn); // Execute a query NpgsqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { Pit pit = GetPitFromDR(dr); retval.Add(pit); } conn.Close(); return(retval); }
public void Hit(Node newNode, float speed) { if (newNode == null) { Hit(); return; } BackInTimeManager.inst.AddAction(new TurnActionMoveHit(crtNode, durability, this)); HitAction(); //crtNode.rock = null; //LevelManager.inst.UpdateRockNode(crtNode, this, newNode); //crtNode = newNode; //crtNode.rock = this; Pit pit = LevelManager.inst.IsAPit(newNode); if (pit != null) { pit.FullIt(); m_onAPit = true; //m_transform.position = crtNode.worldPosition + Vector3.down; Debug.Log("Rock is on a pit", gameObject); StartCoroutine(HitAnim(newNode, speed, true)); } else { StartCoroutine(HitAnim(newNode, speed, false)); } //m_transform.position = crtNode.worldPosition; }
public override Pit[] MakeBoard(int n) { NormalPit[] p1 = new NormalPit[n]; NormalPit[] p2 = new NormalPit[n]; for (int i = 0; i < n; i++) { p1[i] = new NormalPit(4); p2[i] = new NormalPit(4); if (i > 0) { p1[i - 1].next = p1[i]; p2[i - 1].next = p2[i]; } } for (int i = 0; i < n; i++) { p1[i].opposite = p2[n - i - 1]; p2[i].opposite = p1[n - i - 1]; } p1[p1.Length - 1].next = p2[0]; p2[p2.Length - 1].next = p1[0]; Pit[] board = new Pit[2 * n]; for (int i = 0; i < n; i++) { board[i] = p1[i]; board[i + n] = p2[i]; } return(board); }
//initializes a random new game public static void Initialize(ref bool play, out Map cave, out Player player, out Wumpus wumpus, out SuperBats bats, out Pit pitA, out Pit pitB) { //will start the main game loop later play = true; //initialize object locations int[] locations = generateLocations(); //creates a new map cave = new Map(20, locations[0], locations[1], locations[2], locations[3], locations[4]); //creates the player player = new Player(cave.Oloc[0]); //creates the wumpus wumpus = new Wumpus(cave.Oloc[1]); //creates a group of super bats bats = new SuperBats(cave.Oloc[2]); //creates a pit pitA = new Pit(cave.Oloc[3]); //creates a pit pitB = new Pit(cave.Oloc[4]); Console.WriteLine("HUNT THE WUMPUS - A new cave has been generated"); }
public static bool UpdatePit(Pit pit) { // create and open a connection NpgsqlConnection conn = DatabaseConnection.GetConnection(); conn.Open(); // Define a query string query = "UPDATE pits " + " SET \"intSeat\" = @intSeat," + " \"intMemberID\" = @intMemberID" + " WHERE \"intPitID\" = @intPitID;"; NpgsqlCommand cmd = new NpgsqlCommand(query, conn); //cmd.Parameters.AddWithValue("strInstrument", pit.StrInstrument); cmd.Parameters.AddWithValue("intSeat", pit.IntSeat); cmd.Parameters.AddWithValue("intPitID", pit.IntPitID); cmd.Parameters.AddWithValue("intMemberID", pit.IntMemberID); //cmd.Parameters.AddWithValue("intShowID", pit.IntShowID); // Execute a query int result = cmd.ExecuteNonQuery(); conn.Close(); if (result == 1) { return(true); } else { return(false); } }
public static Pit GetPit(int intPitID) { Pit retval = null; // create and open a connection NpgsqlConnection conn = DatabaseConnection.GetConnection(); conn.Open(); // Define a query string query = "SELECT * FROM pits WHERE \"intPitID\" = " + intPitID; NpgsqlCommand cmd = new NpgsqlCommand(query, conn); // Execute a query NpgsqlDataReader dr = cmd.ExecuteReader(); // Read all rows and output the first column in each row while (dr.Read()) { retval = GetPitFromDR(dr); //Console.Write("{0}\n", dr[0]); } conn.Close(); return(retval); }
IEnumerator PitStop(float stopTime, float laneSpeed) { state = 3; Debug.Log("I'm in pit stop mode"); Pit pit = CommonReferences.trackData.pit; transform.position = pit.entryWayPoint.pos; transform.rotation = Quaternion.Euler(0, 0, pit.angle); Debug.Log(Vector2.Distance(transform.position, trackDataHolder.GetPitPos(3))); while (Vector2.Distance(transform.position, trackDataHolder.GetPitPos(3)) > 0.1f) { yield return(new WaitForFixedUpdate()); transform.Translate(Vector3.right * Time.deltaTime * laneSpeed); Debug.Log("moving at " + Time.deltaTime * laneSpeed); } for (int i = 0; i < 40; i++) { yield return(new WaitForFixedUpdate()); transform.Translate(Vector3.right * Time.deltaTime * laneSpeed); transform.Rotate(Vector3.forward * -1f); } for (int i = 0; i < 40; i++) { //yield return new WaitForEndOfFrame(); yield return(null); transform.Translate(Vector3.right * Time.deltaTime * laneSpeed); transform.Rotate(Vector3.back * -1f); } Debug.Log("Stop !"); yield return(new WaitForSeconds(stopTime)); Debug.Log("Gogogo !"); for (int i = 0; i < 40; i++) { yield return(new WaitForFixedUpdate()); transform.Translate(Vector3.right * Time.deltaTime * laneSpeed); transform.Rotate(Vector3.back * -1f); } for (int i = 0; i < 40; i++) { yield return(new WaitForFixedUpdate()); transform.Translate(Vector3.right * Time.deltaTime * laneSpeed); transform.Rotate(Vector3.forward * -1f); } while (state == 3) { yield return(new WaitForFixedUpdate()); transform.Translate(Vector3.right * Time.deltaTime * laneSpeed); Debug.Log("moving at " + Time.deltaTime * laneSpeed); } wpObjective = pit.indexAfterPit; speed = laneSpeed; }
public Vector2 GetPitPos(int carIndex) { Pit pit = trackData.pit; Vector2 pos = new Vector2(); float correctedIndex = Map(carIndex, 0, 5, -1, 1); pos = pit.pos + new Vector2(Mathf.Cos(pit.angle * Mathf.Deg2Rad) * pit.length / 2, Mathf.Sin(pit.angle * Mathf.Deg2Rad) * pit.length / 2) * correctedIndex; return(pos); }
public void AddPit(float xBase, float yBase, float radius, float[,] backup) { Pit pit = new Pit(terrainData, flower); pit.xBase = xBase; pit.yBase = yBase; pit.radius = radius; pit.backup = backup; pits.Add(pit); }
public void ShowDetails(Pit pit) { ResetFields(); TeamNumber.Content += pit.TeamNumber.ToString(); Chassis.Content += pit.Chassis; AutoDiscription.Content += pit.AutonomousDescription; AutonomousOptions.Content += pit.AutonomousOptions.ToString(); ClimbAble.Content += pit.Climb ? "The robot can climb" : "The robot can not climb"; MiddleAuto.Content += pit.MiddleAutonomous ? "Has middle autonomous" : "Doesn't has middle autonomous"; }
private void DetailsButtonOnClick(object sender, RoutedEventArgs e) { MsgLabel.Visibility = Visibility.Collapsed; CustomListViewColumn column = (CustomListViewColumn)sender; int idx = CustomListView.ItemList.Children.IndexOf(column); Pit pit = DataLists.GetPits()[idx]; PitDetailsExpander.IsExpanded = true; PitDetails.ShowDetails(pit); }
public void UpdatePitNode(Node previousNode, Pit pit, Node newNode) { if (previousNode != null) { m_pits.Remove(previousNode); } if (newNode != null) { m_pits.Add(newNode, pit); } }
public override void MoveEnd(Pit pit, Player player) { //end in pit not of player if (pit.owner != player) { if (pit.stones > 1 && pit.stones < 4) { //take stones player.collector.CollectStones((pit as NormalPit).takeStones()); } } }
public Pit IsAPit(Node node) { Pit pit = null; m_pits.TryGetValue(node, out pit); if (pit != null && (pit.full || !pit.gameObject.activeSelf)) { pit = null; } return(pit); }
/// <summary> /// /// </summary> /// <param name="pit">Pit handle</param> /// <param name="dungeon">Dungeon handle</param> public PitControl(Pit pit, Dungeon dungeon) { InitializeComponent(); Dungeon = dungeon; IsHiddenBox.Checked = pit.IsHidden; IsIllusionBox.Checked = pit.IsIllusion; TargetBox.SetTarget(dungeon, pit.Target); DamageBox.Dice = pit.Damage; DifficultyBox.Value = pit.Difficulty; Pit = pit; }
public virtual string GetDisplayName() { string name = ""; if (Pit.Any()) { name += Pit + "/" + (LevelIndex + 1); } else { name += World; } return(name); }
public override Pit[] MakeBoard(int n) { NormalPit[] p1 = new NormalPit[n]; NormalPit[] p2 = new NormalPit[n]; //construct pits for (int i = 0; i < n; i++) { p1[i] = new NormalPit(4); p2[i] = new NormalPit(4); //connect pits. if (i > 0) { p1[i - 1].next = p1[i]; p2[i - 1].next = p2[i]; } } //connect opposite pits for (int i = 0; i < n; i++) { p1[i].opposite = p2[n - i - 1]; p2[i].opposite = p1[n - i - 1]; } //make homepits HomePit hp1 = new HomePit(0); HomePit hp2 = new HomePit(0); //connect homepist, and ends p1[p1.Length - 1].next = hp1; hp1.next = p2[0]; p2[p2.Length - 1].next = hp2; hp2.next = p1[0]; //convert to one board array Pit[] board = new Pit[2 * n + 2]; board[n] = hp1; board[2 * n + 1] = hp2; for (int i = 0; i < n; i++) { board[i] = p1[i]; board[i + n + 1] = p2[i]; } return(board); }
private static Pit GetPitFromDR(NpgsqlDataReader dr) { int intPitID = Convert.ToInt32(dr["intPitID"]); string strInstrument = dr["strInstrument"].ToString(); int intSeat = Convert.ToInt32(dr["intSeat"]); int intMemberID = Convert.ToInt32(dr["intMemberID"]); int intShowID = Convert.ToInt32(dr["intShowID"]); Show show = ShowsDAL.GetShow(intShowID); Member member = MembersDAL.GetMember(intMemberID); Pit pit = Pit.Of(intPitID, strInstrument, intSeat, intMemberID, member, intShowID, show); return(pit); }
public override bool NextPlayer(Pit pit, Player player) { //end in own homepit if (pit is HomePit) { return(true); } //end in a non empty pit if (pit.stones > 0) { return(false); } //other return(true); }
void OnTriggerEnter(Collider other) { if(other.gameObject.GetComponent("Client") != null) //You can change this script to any script that only the player has { Debug.Log("Colliding"); if (TrapType == (int) Traps.LT_PIT) { Pit p = new Pit(); p.Activate(character,SpawnPoint); } else if(TrapType == (int) Traps.LT_DOOR) { Door d = new Door(); d.Activate(character,NextDoor); } } }
public Tile GetTile(PitTileData t) { SetMinimapTile(Color.Orange); var pitInitializer = new PitInitializer { Imaginary = t.Imaginary, Invisible = t.Invisible, IsOpen = t.IsOpen }; var res = new Pit(pitInitializer); sidesCreator.SetupSidesAsync(pitInitializer, currentGridPosition, res); res.Renderer = builder.Factories.RenderersSource.GetPitTileRenderer(res); initializer = pitInitializer; return(res); }
public ActionResult DeletePit(int IntPitID) { Pit remPit = new Pit { IntPitID = IntPitID }; bool success = PitsDAL.DeletePit(remPit); PitsVM model = new PitsVM() { LstPits = PitsDAL.GetAllPits(), LstAllMembers = MembersDAL.GetAllMembers(), LstAllShows = ShowsDAL.GetAllShows() }; return(PartialView("CRUDPartials/_Pits", model)); }
public override void MoveEnd(Pit pit, Player player) { //end in own homepit if (pit is HomePit) { //go again if (pit == player.collector) { player.Move(this); } return; } //end in own pit, and opposite pit contains stones if ((pit as NormalPit).opposite.stones != 0 && pit.owner == player) { //take stones, and place them in own homepit player.collector.CollectStones((pit as NormalPit).opposite.takeStones() + (pit as NormalPit).takeStones()); } }
public ActionResult UpdatePit(int IntPitID, int IntSeat, int IntMemberID) { Pit upPit = new Pit { IntPitID = IntPitID, IntSeat = IntSeat, IntMemberID = IntMemberID, Member = MembersDAL.GetMember(IntMemberID) }; bool success = PitsDAL.UpdatePit(upPit); PitsVM model = new PitsVM() { LstPits = PitsDAL.GetAllPits(), LstAllMembers = MembersDAL.GetAllMembers(), LstAllShows = ShowsDAL.GetAllShows() }; return(PartialView("CRUDPartials/_Pits", model)); }
private void Button_Click(object sender, RoutedEventArgs e) { var pit = new Pit(int.Parse(TeamNumber.Text)) { AutonomousOptions = int.Parse(AutoOptions.Text), Climb = ClimbAble.IsChecked != null && (bool)ClimbAble.IsChecked, MiddleAutonomous = MiddleAuto.IsChecked != null && (bool)MiddleAuto.IsChecked, Chassis = SelectedChassis(), AutonomousDescription = AutoDescriptionContent() }; MsgLabel.Visibility = Visibility.Visible; if (!DataLists.AddPit(pit)) { MsgLabel.ShowMessage("Can't send pit to server.\nPlease check your internet connection.", true); } else { MsgLabel.ShowMessage("Pit has successfully saved!", false); } }
void Start() { if (testing) { movement = 1f; } animate = GetComponent <Animator>(); pit = pitGO.GetComponent <Pit>(); //Set endpoints of movingplatforms BoxCollider2D[] cols = GetComponentsInChildren <BoxCollider2D>(); rightSide = (transform.position.x > cols[1].transform.position.x || transform.position.y > cols[1].transform.position.y); leftSide = !rightSide; if (axis) { platColliders[1] = (transform.position.x > cols[1].transform.position.x) ? transform.position.x : cols[1].transform.position.x; platColliders[0] = (transform.position.x > cols[1].transform.position.x) ? cols[1].transform.position.x : transform.position.x; } else { platColliders[1] = (transform.position.y > cols[1].transform.position.y) ? transform.position.y : cols[1].transform.position.y; platColliders[0] = (transform.position.y > cols[1].transform.position.y) ? cols[1].transform.position.y : transform.position.y; } destinationTime = clock + moveTime; Destroy(cols[1].gameObject); storePlat = onPlat; storeLeft = leftSide; storeRight = rightSide; storeLoc = (Vector2)transform.position; }
//Checks collision to take damage, heal, or rach the goal private void OnCollisionEnter2D(Collision2D collision) { Master cross = collision.collider.GetComponent <Master>(); if (cross != null) { Hurt(); } Patrol patrol = collision.collider.GetComponent <Patrol>(); if (patrol != null) { Hurt(); } Health_Bottle healthBottle = collision.collider.GetComponent <Health_Bottle>(); if (healthBottle != null) { Heal(); } Pit pit = collision.collider.GetComponent <Pit>(); if (pit != null) { Fall(); } Goal goal = collision.collider.GetComponent <Goal>(); if (goal != null) { Scene currentScene = SceneManager.GetActiveScene(); SceneManager.LoadScene(currentScene.buildIndex + 1); } AxePickup axePickup = collision.collider.GetComponent <AxePickup>(); if (axePickup != null) { axeActive = true; } }
public ActionResult InsertPit(string StrInstrument, int IntSeat, int IntMemberID, int IntShowID) { Pit newPit = new Pit { StrInstrument = StrInstrument, IntSeat = IntSeat, IntMemberID = IntMemberID, Member = MembersDAL.GetMember(IntMemberID), IntShowID = IntShowID, Show = ShowsDAL.GetShow(IntShowID) }; bool success = PitsDAL.InsertPit(newPit); PitsVM model = new PitsVM() { LstPits = PitsDAL.GetAllPits(), LstAllMembers = MembersDAL.GetAllMembers(), LstAllShows = ShowsDAL.GetAllShows() }; return(PartialView("CRUDPartials/_Pits", model)); }
private static void DrawPit(Pit pit, int left, int top) { //first lines Console.SetCursorPosition(left, top); Console.Write("+-----+"); Console.SetCursorPosition(left, top + 1); Console.Write("| |"); Console.SetCursorPosition(left, top + 2); //number of stones in pit string line = "| |"; int l = pit.stones.ToString().Length; line = line.Remove(3 - (l - 1) / 2, l); line = line.Insert(3 - (l - 1) / 2, pit.stones.ToString()); Console.Write(line); //last lines Console.SetCursorPosition(left, top + 3); Console.Write("| |"); Console.SetCursorPosition(left, top + 4); Console.Write("+-----+"); }
public virtual void ActivateContent(Pit t){}
/// <summary>Sets the size of the game board in terms of pits per player and initial number of seeds. /// Allocates the internal structures accordingly.</summary> /// <param name="numHousesPerPlayer">The number of houses per player</param> /// <param name="numInitialSeeds">The number of seeds initially stored in each pit</param> public void SetSize(int numHousesPerPlayer, int numInitialSeeds) { // Initialize the private member that stores the number of pits: _numHousesPerPlayer = numHousesPerPlayer; // For each player the given number of pits is reserved plus the two Kalahs: _numPitsInTotal = (_numHousesPerPlayer + 1) * 2; // Set the initial number of seeds in a house: _numInitialSeeds = numInitialSeeds; // Create the array of pits which quite frankly defines the gameboard. _pit = new Pit[_numPitsInTotal]; for (int index = 0; index < _numPitsInTotal; ++index) { if ((index == _numHousesPerPlayer) || (index == (_numPitsInTotal - 1))) { // This is the index of a Kalah --> initially 0 seeds: _pit[index] = new Pit(0); } else { // This is the index of a pit --> initially n seeds: _pit[index] = new Pit(_numInitialSeeds); } } }
public static void Test(){ int[] a = {0, 1, 3, -2, 0, 1, 0, -3, 2, 3 }; Pit p = new Pit(); Console.WriteLine(p.FindPit(a)); }
void Start() { hazard_cap = 2; wumpusCave = new Cave(); player = new Player("Hunter"); wumpus = new Wumpus("Wumpy"); bats = new List<Bat>(hazard_cap); pits = new List<Pit>(hazard_cap); //init bats & pits for (int i = 0; i < hazard_cap; i++ ){ Bat bat = new Bat(i.ToString()); bats.Add(bat); Pit pit = new Pit(i); pits.Add(pit); } positions = new int[6]; setup(1); //assign player references to controllers //*I don't like it but I run into Object reference not set to an instance errors otherwise.. inputController = GetComponent<InputController>(); guiController = GameObject.Find("Canvas").GetComponent<GUIController>(); imgController = GetComponent<ImagePlaneController>(); inputController.player = player; guiController.player = player; guiController.gameState = STATE; //assign Room prefabs to a room DAO Transform Rooms = GameObject.Find("WumpusCave/Rooms").GetComponent<Transform>(); UnityEngine.Debug.Log(Rooms.childCount); for(int i = 0; i < Rooms.childCount; i++) Rooms.GetChild(i).GetComponent<RoomBehavior>().room = wumpusCave.rooms[i]; }