void Start() { moving = GetComponent <moving>(); player = GetComponent <CharacterController>(); RobotAnim = GetComponent <Animator>(); driller = GetComponentInChildren <TerrainEditor>(); }
// Use this for initialization void Start() { Grid = new Transform[width, width]; for (int x = 0; x < width; x++) { for (int y = 0; y < width; y++) { Transform item = Instantiate(bricks); SpriteRenderer sprite = item.GetComponent <SpriteRenderer>(); float sizeX = sprite.bounds.size.x; float xCoordinate = bricks.localPosition.x + (sizeX * (x)); float size = sprite.bounds.size.y; sprite.sprite = colors[Random.Range(0, colors.Length)]; item.localPosition = new Vector3(xCoordinate, -(bricks.localPosition.y + (size * (y))), 1); moving movingClass = item.GetComponent <moving>(); movingClass.type = sprite.sprite.name; movingClass.x = x; movingClass.y = y; item.name = sprite.sprite.name + "-" + x + "-" + y; Grid [x, y] = item; } } gridmanager.setGrid(Grid); }
private bool hits_paddle(moving paddle, int nx, int ny, ref int vx, ref int vy) { return(hits_paddle0(paddle, nx - radius, ny - radius, ref vx, ref vy) || hits_paddle0(paddle, nx + radius, ny - radius, ref vx, ref vy) || hits_paddle0(paddle, nx - radius, ny + radius, ref vx, ref vy) || hits_paddle0(paddle, nx + radius, ny + radius, ref vx, ref vy)); }
public void moveRight(Transform tile) { Transform tmp = tile; Vector3 tmpLocalPosition = tile.localPosition; moving currentmoving = tile.GetComponent <moving>( ); Debug.Log(Grid); Debug.Log(Grid [currentmoving.x, currentmoving.y]); if (currentmoving.x < 4) { Debug.Log(Grid [currentmoving.x + 1, currentmoving.y].localPosition); Debug.Log(tmpLocalPosition); Grid [currentmoving.x, currentmoving.y].localPosition = Grid [currentmoving.x + 1, currentmoving.y].localPosition; Grid [currentmoving.x, currentmoving.y] = Grid [currentmoving.x + 1, currentmoving.y]; Grid [currentmoving.x + 1, currentmoving.y].localPosition = tmpLocalPosition; Instantiate(Grid [currentmoving.x + 1, currentmoving.y]); Destroy(tile.GetComponent <GameObject>()); // tmps is ref to tile. // We change tile and tmp. \ // Need to clone game object and destruct previous one Grid [currentmoving.x + 1, currentmoving.y] = tmp; Debug.Log(Grid [currentmoving.x + 1, currentmoving.y].localPosition); Debug.Log(tmpLocalPosition); } }
// Start is called before the first frame update void Start() { transform.localScale = new Vector3(Screen.width / 60 / 8, Screen.width / 60 / 8, 1.0f); transform.position = new Vector3(Screen.width * 0.93f, Screen.height * 0.15f, 0.0f); joystickSc = joystick.GetComponent <moving>(); invSc = inventory.GetComponent <Inventory>(); camSc = camera.GetComponent <movingCamera>(); }
// Start is called before the first frame update void OnTriggerEnter(Collider other) { if (other.CompareTag("Enemy")) { Tesla_tower l = obj.GetComponent <Tesla_tower>(); moving l2 = other.GetComponent <moving>(); l.addenemy(other.gameObject, l2.whalk_in); } }
// Use this for initialization void Start() { //dashInputScript = GetComponent<get_input>(); playerStateScript = GetComponent <player_state>(); movingScript = GetComponent <moving>(); throwingScript = GetComponent <throwing>(); animator = transform.GetChild(1).gameObject.GetComponent <Animator> (); soundPlayer = GameObject.FindGameObjectWithTag("Sound_Player").GetComponent <sound_player>(); }
// Use this for initialization void Start() { //dashInputScript = GetComponent<get_input>(); playerStateScript = GetComponent<player_state>(); movingScript = GetComponent<moving>(); throwingScript = GetComponent<throwing>(); animator = transform.GetChild(1).gameObject.GetComponent<Animator> (); soundPlayer = GameObject.FindGameObjectWithTag ("Sound_Player").GetComponent<sound_player>(); }
public void check_new_ball(int row, int col) { int n = 1; char ch = b.get_tile(row, col); if ((ch >= '0') && (ch <= '9')) { n = (int)(ch - '0'); b.hit(row, col); ch = b.get_tile(row, col); } if (ch == 'o') { int x = (breakout_definitions.x_res * col) / breakout.max_col; int y = (breakout_definitions.y_res * row) / breakout.max_row; while (n > 0) { System.Console.WriteLine("new ball {0}, x = {1}, y = {2}", n, x, y); if (n > 0) { moving m = new moving(); m.ball(x, y, -1, -1, 8); move_list.Add(m); } if (n > 1) { moving m = new moving(); m.ball(x + 10, y, 1, -1, 8); move_list.Add(m); } if (n > 2) { moving m = new moving(); m.ball(x, y + 10, -1, 1, 8); move_list.Add(m); } if (n > 3) { moving m = new moving(); m.ball(x + 10, y + 10, 1, 1, 8); move_list.Add(m); } n -= 4; } b.hit(row, col); } }
// Use this for initialization void Start() { inputScript = gameObject.GetComponent<get_input>(); playerStateScript = gameObject.GetComponent<player_state>(); movingScript = gameObject.GetComponent<moving>(); pearlOffset = transform.GetChild(0).gameObject; pearlRenderer = pearlOffset.GetComponent<SpriteRenderer>(); anim = pearlOffset.GetComponent<Animator> (); throwAngle = 0.0f; aimingThreshold = 0.001f; // if this value is too high the aiming tends to snap to the NSEW directions (0.2 was too high) }
// Use this for initialization void Start() { inputScript = gameObject.GetComponent <get_input>(); playerStateScript = gameObject.GetComponent <player_state>(); movingScript = gameObject.GetComponent <moving>(); pearlOffset = transform.GetChild(0).gameObject; pearlRenderer = pearlOffset.GetComponent <SpriteRenderer>(); anim = pearlOffset.GetComponent <Animator> (); throwAngle = 0.0f; aimingThreshold = 0.001f; // if this value is too high the aiming tends to snap to the NSEW directions (0.2 was too high) }
void Start() { //get the state script playerStateScript = GetComponent <player_state> (); //get the GameObject beaverSprite = transform.GetChild(1).gameObject; beaverMouth = transform.GetChild(1).gameObject; beaverPearlCollider = beaverSprite.transform.GetChild(0).gameObject; // get Player name form patent object Player_name = gameObject.transform.name; //gettign the scripts that will be disabled movingScript = GetComponent <moving> (); dashScript = GetComponent <dash> (); throwingScript = GetComponent <throwing> (); colDetectScript = GetComponent <collision_detection> (); //get the scripts to animate the indicator // if (Player_name == "Beaver1") { // iconIndicator = GameObject.FindGameObjectWithTag ("iconP1").GetComponent<Animator>(); // // } else if (Player_name == "Beaver2") { // iconIndicator = GameObject.FindGameObjectWithTag ("iconP2").GetComponent<Animator>(); // } //getting the particle system Bubbles = beaverMouth.GetComponentInChildren <ParticleSystem> (); //setting the emmision to 0 Bubbles.emissionRate = 0; //initially not suffocating //isSuffocating = false; playerStateScript.SetIsSuffocating(false); // gettign the ridgit body of the Player rBody = GetComponent <Rigidbody2D> (); // getting the animator. animator = transform.GetChild(1).gameObject.GetComponent <Animator> (); soundPlayer = GameObject.FindGameObjectWithTag("Sound_Player").GetComponent <sound_player>(); }
void Start() { r_body = GetComponent <Rigidbody2D>(); dashInputScript = GetComponent <get_input>(); playerStateScript = GetComponent <player_state>(); movingScript = GetComponent <moving>(); // throwingScript = GetComponent<throwing>(); soundPlayer = GameObject.FindGameObjectWithTag("Sound_Player").GetComponent <sound_player>(); //get reference to the animator located on the beaver_sprite child object beaverSprite = transform.GetChild(1).gameObject; animator = beaverSprite.GetComponent <Animator>(); }
void Update() { money = Robot.GetComponentInChildren <PickUp>(); health = Robot.GetComponentInChildren <moving>(); if (ui.picPickUp) { PicAxe1.SetActive(true); PicAxe2.SetActive(true); PicAxe3.SetActive(true); } if (ui.jetPickUp) { jet.SetActive(true); } }
void init_board() { moving p = new moving(); moving b = new moving(); p.default_paddle(); b.default_ball(); move_list.Clear(); move_list.Add(p); // first item in the list is always the paddle move_list.Add(b); redraw_screen(); p.draw(context); }
void OnTriggerEnter(Collider other) { if (other.CompareTag("Enemy")) { look_around l = obj.GetComponent <look_around>(); if (other.GetComponent <moving>() != null) { moving l2 = other.GetComponent <moving>(); l.addenemy(other.transform, l2.whalk_in); } else { l.addenemy(other.transform, 0); } } }
private void attackE() { attackClose(); //hide the attackPanel if (this.AttackPanel != null) { this.AttackPanel.SetActive(false); } //next stage this.currentStage = 2; this.mo = new moving(this.currentPlayer, Global.map); //show the movekPanel if (this.MovePanel != null) { this.MovePanel.SetActive(true); } }
/// <summary> /// define all the variables /// </summary> private void Start() { this.getInputCountry = int.MaxValue; this.currentPlayer = 0; this.currentStage = 3; this.forcesPanel = GameObject.Find("forcesPanel"); //set the panels this.startPanel = GameObject.Find("StartPanel"); if (this.startPanel != null) { this.startPanel.SetActive(false); } this.AttackPanel = GameObject.Find("AttackPanel"); if (this.AttackPanel != null) { this.AttackPanel.SetActive(false); } this.ReiPanel = GameObject.Find("ReinforcementPanel"); if (this.ReiPanel != null) { this.ReiPanel.SetActive(false); } this.MovePanel = GameObject.Find("MovingPanel"); if (this.MovePanel != null) { this.MovePanel.SetActive(false); } this.WPanel = GameObject.Find("WinPanel"); if (this.WPanel != null) { this.WPanel.SetActive(false); } this.st = null; this.rei = null; this.sm = null; this.at = null; this.mo = null; this.bot = null; }
private bool hits_paddle0(moving paddle, int nx, int ny, ref int vx, ref int vy) { int paddle_boarder = 2; // hits top left corner if ((nx == paddle.x) && (ny == paddle.y + breakout_definitions.paddle_height)) { vx = -vx; vy = -vy; return(true); } // hits top right corner if ((nx == paddle.x + breakout_definitions.paddle_width) && (ny == paddle.y + breakout_definitions.paddle_height)) { vx = -vx; vy = -vy; return(true); } // hits top if ((ny == paddle.y - paddle_boarder) && ((nx >= paddle.x) && (nx <= paddle.x + breakout_definitions.paddle_width))) { vy = -vy; return(true); } // hits left or right if ((in_range(ny, paddle.y, paddle.y + breakout_definitions.paddle_height)) && ((nx == paddle.x) || (nx == paddle.x + breakout_definitions.paddle_width))) { vx = -vx; vy = -vy; return(true); } return(false); }
public void move(Context context, moving paddle, breakout b, gamewindow g) { if ((vx != 0) || (vy != 0)) { int nx = Math.Min(Math.Max(x + vx, 0), breakout_definitions.x_res); int ny = Math.Min(Math.Max(y + vy, 0), breakout_definitions.y_res); if (moving_type == moving_types.ball_t) { if (hits_paddle(paddle, nx, ny, ref vx, ref vy)) { ; } else if (hits_brick(context, nx, ny, ref vx, ref vy, b, g)) { ; } else if (hits_wall(nx, ny, ref vx, ref vy)) { ; } else if (falls_below(context, ny)) { ; } else { draw_if_moved(context, nx, ny); } } else { draw_if_moved(context, nx, ny); } } }
public void update_ai_mover(long c_tm) { if (c_tm <= next_mov_tm) return; long now = DateTime.Now.ToBinary(); if (this.mondata.patrol == null && this.mondata.moving == null && this.mondata.speed > 0) { bool ifmove = false; Point2D grid = new Point2D(this.mondata.init_x, this.mondata.init_y); int start_x = (int)grid.x - this.mondata.r_x; int start_y = (int)grid.y - this.mondata.r_y; if (start_x < 0) start_x = 0; if (start_y < 0) start_y = 0; int end_x = start_x + 2 * this.mondata.r_x; int end_y = start_y + 2 * this.mondata.r_y; Point2D cur_grid = new Point2D(this.mondata.x / StaticStuff.GRID_WIDTH, this.mondata.y / StaticStuff.GRID_WIDTH); if (start_x > cur_grid.x || start_y > cur_grid.y || end_x < cur_grid.x || end_y < cur_grid.y) ifmove = true; else { if (this.monconf.ai.mover > 0 && new Random().Next(0, 100) < monconf.ai.mover) { ifmove = true; } } if (ifmove && this.mondata.speed > 0) { int to_x = Utility.random(start_x, end_x + 1); int to_y = Utility.random(start_y, end_y + 1); List<Point2D> path = Utility.findPath(this.gmap.mapid, cur_grid, new Point2D(to_x, to_y)); if (null != path && path.Count > 0) { moving move = new moving(); this.mondata.moving = move; move.start_tm = now; move.pts = path; move.to_x = to_x; move.to_y = to_y; move.float_x = this.mondata.x; move.float_y = this.mondata.y; //TODO broadcast } } } this.next_mov_tm = now + this.monconf.ai.thinktm; }
/// <summary> /// one of the main functions, get the wanted territory from countryHnadler(the player) and play the game /// </summary> /// <param name="input">index of the country</param> public void getInput(int input) { //dont get input before the user declare the players if (this.forcesPanel != null) { if (this.forcesPanel.activeSelf == false) { bool flag_next_player = false; //the player lost already if (players[this.currentPlayer] == false) { //move to next player nextPlayer(); } else { if (this.counter == 0) { this.inputInexOfCou = input; //in the choose teritories stage if (this.currentStage == 3) { bool flag_to_attack = false; flag_next_player = chooseTer(this.inputInexOfCou); //still need to be deployed if (this.st.num_of_players > 0) { //the player picked good if (flag_next_player == true) { nextPlayer(); //already moved so no need to move it flag_next_player = false; //while the player is bot while (this.st.num_of_players > 0 && this.playerAi[this.currentPlayer] == true) { //make a move as ai this.bot = new Ai(this.currentPlayer); this.bot.makeMoveInStart(this.st); //all the soldiers werent deployed if (this.st.num_of_players > 0) { nextPlayer(); } else { flag_to_attack = true; } } } } //all the soldiers of all players were deployed else { flag_to_attack = true; } if (flag_to_attack == true) { //hide the startPanel if (this.startPanel != null) { this.startPanel.SetActive(false); } this.currentStage = 1; //move to next player nextPlayer(); flag_next_player = false; this.at = new Attack(this.currentPlayer, Global.map); if (this.AttackPanel != null) { this.AttackPanel.SetActive(true); } } } //in the choose reinfoesment stage else if (this.currentStage == 0) { //check if all the soldiers were deployed if (this.rei.getNumberOfForces() <= 0) { //hide the reinforsment Panel if (this.ReiPanel != null) { this.ReiPanel.SetActive(false); } //next stage this.currentStage = 1; this.at = new Attack(this.currentPlayer, Global.map); //show the attackPanel if (this.AttackPanel != null) { this.AttackPanel.SetActive(true); } } else { //allow to reinforse if (this.ReiPanel.transform.Find("conf") != null) { this.ReiPanel.transform.Find("conf").gameObject.SetActive(true); } if (this.ReiPanel.transform.Find("SliderText") != null) { this.ReiPanel.transform.Find("SliderText").gameObject.SetActive(true); } if (this.ReiPanel.transform.Find("Slider") != null) { this.ReiPanel.transform.Find("Slider").gameObject.SetActive(true); } this.ReiPanel.transform.Find("Slider").GetComponent <Slider>().maxValue = this.rei.getNumberOfForces(); this.ReiPanel.transform.Find("Slider").GetComponent <Slider>().minValue = 1; } } //on the attack stage else if (this.currentStage == 1) { //create the list of possible location at.possible_sources(); //can attack if (at.possibleToAttack() == true) { //a possible location was selcted if (at.in_possible_sources(this.inputInexOfCou)) { //show text if (this.AttackPanel.transform.Find("ataText") != null) { this.AttackPanel.transform.Find("ataText").gameObject.SetActive(true); } this.counter++; } } else { //next stage //hide the attackPanel if (this.AttackPanel != null) { this.AttackPanel.SetActive(false); } this.currentStage = 2; this.mo = new moving(this.currentPlayer, Global.map); //show the movekPanel if (this.MovePanel != null) { this.MovePanel.SetActive(true); } } } // on the move forces else { //create all the possble source this.mo.possible_source(); //can move if (this.mo.canMove() == true) { if (this.mo.canChooseSou(this.inputInexOfCou)) { this.mo.possible_des(this.inputInexOfCou); this.mo.removeSelf(this.inputInexOfCou); //show text if (this.MovePanel.transform.Find("first") != null) { this.MovePanel.transform.Find("first").gameObject.SetActive(true); } this.counter++; } } else { moveNextStage(); } } //reinforsment //attack //check win //move } //one teritory was already chosen else if (this.counter == 1) { this.inputInexOfCou2 = input; //on the attack stage if (this.currentStage == 1) { //the selcted des can be attacked if (at.destention_is_possible(this.inputInexOfCou2, this.inputInexOfCou)) { //show text if (this.AttackPanel.transform.Find("defText") != null) { this.AttackPanel.transform.Find("defText").gameObject.SetActive(true); } //show buttons if (this.AttackPanel.transform.Find("withdraw") != null) { this.AttackPanel.transform.Find("withdraw").gameObject.SetActive(true); } if (this.AttackPanel.transform.Find("cont") != null) { this.AttackPanel.transform.Find("cont").gameObject.SetActive(true); } this.counter++; } } //the sourse location was chosen in the moving stage else if (this.currentStage == 2) { if (this.mo.canChooseDes(this.inputInexOfCou2)) { //show text if (this.MovePanel.transform.Find("SliderText") != null) { this.MovePanel.transform.Find("SliderText").gameObject.SetActive(true); } //show slider if (this.MovePanel.transform.Find("Slider") != null) { this.MovePanel.transform.Find("Slider").gameObject.SetActive(true); } //show button if (this.MovePanel.transform.Find("Button") != null) { this.MovePanel.transform.Find("Button").gameObject.SetActive(true); } this.counter++; this.MovePanel.transform.Find("Slider").GetComponent <Slider>().maxValue = Global.map.map[this.inputInexOfCou].Info.Num_of_forces - 1; this.MovePanel.transform.Find("Slider").GetComponent <Slider>().minValue = 1; } } } if (flag_next_player == true) { //move to next player nextPlayer(); } } } } }
public static void Unlock() { xrState = size.mutate; yrState = size.mutate; vState = moving.straight; hState = moving.straight; }
void Start() { //get the state script playerStateScript = GetComponent<player_state> (); //get the GameObject beaverSprite = transform.GetChild (1).gameObject; beaverMouth = transform.GetChild (1).gameObject; beaverPearlCollider = beaverSprite.transform.GetChild (0).gameObject; // get Player name form patent object Player_name = gameObject.transform.name; //gettign the scripts that will be disabled movingScript = GetComponent<moving> (); dashScript = GetComponent<dash> (); throwingScript = GetComponent<throwing> (); colDetectScript = GetComponent<collision_detection> (); //get the scripts to animate the indicator // if (Player_name == "Beaver1") { // iconIndicator = GameObject.FindGameObjectWithTag ("iconP1").GetComponent<Animator>(); // // } else if (Player_name == "Beaver2") { // iconIndicator = GameObject.FindGameObjectWithTag ("iconP2").GetComponent<Animator>(); // } //getting the particle system Bubbles = beaverMouth.GetComponentInChildren<ParticleSystem> (); //setting the emmision to 0 Bubbles.emissionRate = 0; //initially not suffocating //isSuffocating = false; playerStateScript.SetIsSuffocating (false); // gettign the ridgit body of the Player rBody = GetComponent<Rigidbody2D> (); // getting the animator. animator = transform.GetChild (1).gameObject.GetComponent<Animator> (); soundPlayer = GameObject.FindGameObjectWithTag ("Sound_Player").GetComponent<sound_player>(); }
public static void LockPosition() { // push position states outside the markov chain state machine vState = moving.locked; // position cannot change hState = moving.locked; }
public static void Reset() { currentPosition = Vector3.zero; vState = moving.straight; hState = moving.straight; xRadius = radiusMax; yRadius = radiusMax; }
void Start() { r_body = GetComponent<Rigidbody2D>(); dashInputScript = GetComponent<get_input>(); playerStateScript = GetComponent<player_state>(); movingScript = GetComponent<moving>(); // throwingScript = GetComponent<throwing>(); soundPlayer = GameObject.FindGameObjectWithTag ("Sound_Player").GetComponent<sound_player>(); //get reference to the animator located on the beaver_sprite child object beaverSprite = transform.GetChild(1).gameObject; animator = beaverSprite.GetComponent<Animator>(); }
private static void NextPosition() { ticker++; // Next positions are calculated using a Markov Chain style state machine // http://en.wikipedia.org/wiki/Markov_chain // float roll = Random.value; // random float between 0 and 1 /* Determine new state */ switch (vState) { case moving.positive2: if (roll > 0.75f) vState = moving.positive; // 25% chance else vState = moving.positive2; // 75% chance break; case moving.positive: if (roll > 0.75f) vState = moving.positive2; // 25% else if (roll > 0.25f) vState = moving.positive; // 50% else vState = moving.straight; // 25% break; case moving.straight: if (roll > 0.50f) vState = moving.straight; // 50% else if (roll > 0.25f) vState = moving.positive; // 25% else vState = moving.negative; // 25% break; case moving.negative: if (roll > 0.75f) vState = moving.negative2; else if (roll > 0.25f) vState = moving.negative; else vState = moving.straight; break; case moving.negative2: if (roll > 0.75f) vState = moving.negative; else vState = moving.negative2; break; } switch (hState) { case moving.positive2: if (roll > 0.75f) hState = moving.positive; // 25% chance else hState = moving.positive2; // 75% chance break; case moving.positive: if (roll > 0.75f) hState = moving.positive2; // 25% else if (roll > 0.50f) hState = moving.positive; // 25% else hState = moving.straight; // 50% break; case moving.straight: if (roll > 0.25f) hState = moving.straight; // 75% else if (roll > 0.125f) hState = moving.positive; // 12.5% else hState = moving.negative; // 12.5% break; case moving.negative: if (roll > 0.75f) hState = moving.negative2; else if (roll > 0.50f) hState = moving.negative; else hState = moving.straight; break; case moving.negative2: if (roll > 0.75f) hState = moving.negative; else hState = moving.negative2; break; } /* Determine new position based on new state */ switch (vState) { case moving.positive2: currentPosition += Vector3.up * 1.25f; break; case moving.positive: currentPosition += Vector3.up * 0.75f; break; case moving.negative: currentPosition += Vector3.down * 0.75f; break; case moving.negative2: currentPosition += Vector3.down * 1.25f; break; } switch (hState) { case moving.positive2: currentPosition += Vector3.right * 1.25f; break; case moving.positive: currentPosition += Vector3.right * 0.75f; break; case moving.negative: currentPosition += Vector3.left * 0.75f; break; case moving.negative2: currentPosition += Vector3.left * 1.25f; break; } }
public static void Reset(Vector3 startPosition) { currentPosition = startPosition; currentPosition.z = 0f; vState = moving.straight; hState = moving.straight; xRadius = radiusMax; yRadius = radiusMax; }