public void UpdateControls() { UpdateThrust(); UpdateTurn(); void UpdateThrust() { if (thrusting) { var rotationRads = rotationDegrees * Math.PI / 180; Velocity += XY.Polar(rotationRads, thrust); thrusting = false; fuel--; } } void UpdateTurn() { if (rotating != Rotating.None) { if (rotating == Rotating.CCW) { rotationDegrees += turningSpeed; } else if (rotating == Rotating.CW) { rotationDegrees -= turningSpeed; } rotating = Rotating.None; } } }
public static Rotating set(GameObject target, float rotateVelocity) // указывается цель которая будет вращаться и скорость вращения { Rotating rotating = target.AddComponent <Rotating>(); rotating.m_rotateVelocity = rotateVelocity; return(rotating); }
// Порождение монетки void emitCoin() { int _moneyInOneCoin = moneyInOneCoin; if (totalCount < _moneyInOneCoin) { _moneyInOneCoin = totalCount; } totalCount -= _moneyInOneCoin; //Debug.Log("coin#" + MAIN.testCountCoins + " moneyInOneCoin: "+ _moneyInOneCoin); if (dlFrom != null) { dlFrom.addValue(-_moneyInOneCoin); } GameObject coin = Object.Instantiate(coinPref); coin.GetComponent <Coin>().value = _moneyInOneCoin; Flying f = coin.GetComponent <Flying>(); //Flickering fl = Flickering.set(coin, 0.03f); f.transform.position = new Vector2(target.position.x, target.position.y) + shiftFromPos + Utils.rand(0.03f); //Animation anim = coin.GetComponent<Animation>().clip(); f.init(toTarget.position, fontainPower, new Vector2( Random.Range(-fontainPower * 2.3f, fontainPower * 2.3f), Random.Range(-fontainPower, fontainPower))); f.subscribe(onCoinArrive); // подписываемся на прибитие Rotating.set(coin, Random.Range(-1.0f, 1.0f)); }
void Start() { rigidbody.freezeRotation = true; faction = gameObject.GetComponent<Faction> (); walking = gameObject.GetComponent<Walking> (); rotating = gameObject.GetComponent<Rotating> (); }
/// <summary> /// Stops all movement and rotation /// </summary> public void AllStop() { Speed = 0; AngularSpeed = 0; m_moving = Moving.Stationary; m_rotating = Rotating.Stationary; }
IEnumerator MoveToPosition(Rotating r, Vector3 target) { while (r.transform.localPosition != target) { r.transform.localPosition = Vector3.MoveTowards(r.transform.localPosition, target, 10 * Time.deltaTime); yield return(0); } }
void Start() { text = GetComponentInChildren <TextMesh>(); rotating = GetComponent <Rotating>(); moving = GetComponent <Moving>(); Randomize(); }
// Use this for initialization new void Start() { base.Start (); objectRotation = attachedObject.GetComponent<Rotating> (); rotateSpeed = objectRotation.speed; if (!activated) { objectRotation.speed = 0; } }
public void removeRotating(Rotating r, int id) { Rotate rotate = new Rotate(r, id); if (rotatings.Contains(rotate)) { rotatings.Remove(rotate); } }
void Start() { desiredDirection = Quaternion.identity; walking = gameObject.GetComponent<Walking> (); rotating = gameObject.GetComponent<Rotating> (); shooting = gameObject.GetComponent<Shooting> (); swinging = gameObject.GetComponent<Swinging> (); energy = gameObject.GetComponent<Energy> (); }
// Use this for initialization new void Start() { base.Start(); objectRotation = attachedObject.GetComponent <Rotating> (); rotateSpeed = objectRotation.speed; if (!activated) { objectRotation.speed = 0; } }
private void MakeMap(IMapData mapData) { GameObject[] floor = GameObject.FindGameObjectsWithTag("Floor"); foreach (GameObject obj in floor) { GameObject.Destroy(obj); } GameObject[] end = GameObject.FindGameObjectsWithTag("Endpoint"); foreach (GameObject obj in end) { GameObject.Destroy(obj); } foreach (Vector3 pos in mapData.CubePos) { GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.tag = "Floor"; cube.name = "C" + pos.x + pos.y + pos.z; // 'C'ube cube.transform.position = pos; } for (int i = 0; i < mapData.SlopePos.Length; i++) { GameObject slope = makeSlope(); Vector3 pos = mapData.SlopePos[i]; slope.tag = "Floor"; slope.name = "S" + pos.x + pos.y + pos.z; // 'S'lope slope.transform.position = pos; slope.transform.rotation = mapData.SlopeRot[i]; } foreach (RotatingObject data in mapData.RotObj) { GameObject obj = GameObject.Find(data.name); if (obj == null) { continue; } Rotating script = obj.AddComponent <Rotating>() as Rotating; script.point = data.point; script.axis = data.axis; script.PlayerRot = data.playerRot; } { GameObject player = GameObject.Find("Player"); player.transform.position = new Vector3(mapData.PlayerStart.x, mapData.PlayerStart.y + 1, mapData.PlayerStart.z); // player.GetComponent <MoveCharacter>().Init(); } //关卡终点 { GameObject endpoint = (GameObject)Resources.Load("Prefabs/endpoint"); endpoint.transform.position = mapData.GameEnd; Object.Instantiate(endpoint); } }
void NotContact() { if (isContact) { go_TargetNameBar.gameObject.SetActive(false); isContact = false; Rotating rotating = SpinCoursor.GetComponent <Rotating>(); rotating.Rotate(true); go_ActiveCrosshair.SetActive(false); } }
// Калбэк приходящий непосредственно от самих шаров, при их столкновении с другими шарами, порождает звёзды, а сам шар переводит в состояние "остановлен" public void onNewBallStop(Ball newBall) { main.receivingTray.setBallToStopingBalls(newBall.gameObject); Ticket[] tickets = main.ticketHolder.getTickets(); var rbB = newBall.GetComponent <Rigidbody2D>(); for (int i = 0; (i < main.ticketHolder.transform.childCount && tickets[i] != null); i++) { TicketCell tC = tickets[i].getCellByNum(newBall.number); if (tC) { GameObject flyBall; if (flyingBallsPrefab != null && flyingBallsPrefab.GetComponent <SpriteRenderer>().sprite != null) { flyBall = Instantiate(flyingBallsPrefab); } else { flyBall = Instantiate(newBall.gameObject); } flyBall.transform.parent = flingBalls; Flying f = flyBall.AddComponent <Flying>(); f.destroyOnArrive = false; f.slowdown(3.0f, 0.02f, 0.9f); // #V здесь торможение звёзд: 1 - дистанция с которой начинается торможение, 2 - до скорости, 3 - сила торможения(если 1 то нулевая сила, если 0 то мгновеная остановка, если больше одного наоборот ускорение) flyBall.transform.position = newBall.transform.position; var b = flyBall.GetComponent <Ball>(); if (b != null) { flyBall.name = "flingBall_" + b.number; b.setOrderLayer(9); } var circleCollider = flyBall.GetComponent <CircleCollider2D>(); if (circleCollider != null) { circleCollider.enabled = false; } var rb = flyBall.GetComponent <Rigidbody2D>(); if (rb != null) { Destroy(rb); } var rotating = Rotating.set(flyBall, rbB.angularVelocity); rotating.slowdown(0.1f, 0.96f); // #V замедление вращение звёздочек f.init(tC.transform.position, 0.02f, newBall.prevVelocity[0] * 0.005f); f.subscribe(onBallArrive, tC.gameObject, newBall.gameObject); // #V эффекты на звёздочках: Flickering.set(flyBall, 0.15f); Scaling.set(flyBall, 0.5f, 0.15f); } } }
void MakeMap(IMapData mapData) { GameObject[] objs = GameObject.FindGameObjectsWithTag("Floor"); foreach (GameObject obj in objs) { GameObject.DestroyImmediate(obj); } //foreach (Vector3 pos in mapData.CubePos) for (int i = 0; i < mapData.CubePos.Length; i++) { GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.GetComponent <Renderer>().material.color = Color.red; if (i == mapData.CubePos.Length - 1) { cube.GetComponent <Renderer>().material.color = Color.yellow; } cube.tag = "Floor"; cube.name = "C" + mapData.CubePos[i].x + mapData.CubePos[i].y + mapData.CubePos[i].z; cube.transform.position = mapData.CubePos[i]; } for (int i = 0; i < mapData.SlopePos.Length; i++) { GameObject slope = makeSlope(); slope.GetComponent <Renderer>().material.color = Color.red; Vector3 pos = mapData.SlopePos[i]; slope.tag = "Floor"; slope.name = "S" + pos.x + pos.y + pos.z; slope.transform.position = pos; slope.transform.rotation = mapData.SlopeRot[i]; } foreach (RotatingObject data in mapData.RotObj) { GameObject obj = GameObject.Find(data.name); if (obj == null) { continue; } Rotating script = obj.AddComponent <Rotating>() as Rotating; script.point = data.point; script.axis = data.axis; script.PlayerRot = data.playerRot; } { GameObject player = GameObject.Find("character284"); player.transform.position = new Vector3(mapData.PlayerStart.x, mapData.PlayerStart.y + 1, mapData.PlayerStart.z); player.GetComponent <CharacterMove>().Init(); player.GetComponent <CharacterMove>().getCurrent(mapData.Number); } }
public void addRotating(Rotating r, int id) { Rotate rotate = new Rotate(r, id); if (rotatings.Contains(rotate)) { return; } else { rotatings.Add(rotate); if (id > maxId) { maxId = id; } } }
void Start() { characterStats = GetComponent<CharacterStats>(); attackingRange = characterStats.AttackingRange; GetComponent<SphereCollider>().radius = attackingRange; FXParticleSystem = FXObject.GetComponent<ParticleSystem>(); FXParticleSystem.startSize *= attackingRange; deviceBaseRotating = deviceBase.GetComponent<Rotating>(); if (game == null) { game = Camera.main.GetComponent<Game>(); } lastAttackingTime = Time.time - additionalFXTime - 1; }
void MakeMap(IMapData mapData) { GameObject[] objs = GameObject.FindGameObjectsWithTag("Floor"); foreach (GameObject obj in objs) { GameObject.DestroyImmediate(obj); } foreach (Vector3 pos in mapData.CubePos) { GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.tag = "Floor"; cube.name = "C" + pos.x + pos.y + pos.z; // 'C'ube cube.transform.position = pos; } for (int i = 0; i < mapData.SlopePos.Length; i++) { GameObject slope = makeSlope(); Vector3 pos = mapData.SlopePos[i]; slope.tag = "Floor"; slope.name = "S" + pos.x + pos.y + pos.z; // 'S'lope slope.transform.position = pos; slope.transform.rotation = mapData.SlopeRot[i]; } foreach (RotatingObject data in mapData.RotObj) { GameObject obj = GameObject.Find(data.name); if (obj == null) { continue; } Rotating script = obj.AddComponent("Rotating") as Rotating; script.point = data.point; script.axis = data.axis; script.PlayerRot = data.playerRot; } { GameObject player = GameObject.Find("Player"); player.transform.position = new Vector3(mapData.PlayerStart.x, mapData.PlayerStart.y + 1, mapData.PlayerStart.z); player.GetComponent <MoveCharacter>().Init(); } }
void Contact() { if (hitInfo.transform.CompareTag("Interaction") || hitInfo.transform.CompareTag("Character")) { go_TargetNameBar.SetActive(true); txt_targetName.text = hitInfo.transform.GetComponent <InteractionType>().GetName(); Rotating rotating = SpinCoursor.GetComponent <Rotating>(); rotating.Rotate(true); go_ActiveCrosshair.SetActive(true); if (!isContact) { isContact = true; } } else { NotContact(); } }
public void UpdateControls() { UpdateThrust(); UpdateTurn(); void UpdateThrust() { if (thrusting) { var rotationRads = rotationDegrees * Math.PI / 180; var exhaust = new EffectParticle(Position + XY.Polar(rotationRads, -1), Velocity + XY.Polar(rotationRads, -thrust), new ColoredGlyph(Color.Yellow, Color.Transparent, '.'), 4); World.AddEffect(exhaust); Velocity += XY.Polar(rotationRads, thrust); thrusting = false; } } void UpdateTurn() { if (rotating != Rotating.None) { if (rotating == Rotating.CCW) { rotationDegrees += turningSpeed; } else if (rotating == Rotating.CW) { rotationDegrees -= turningSpeed; } rotating = Rotating.None; } } }
private void MakeMap(IMapData mapData) { RotateController.getInstance().clearRotatings(); GameObject[] floor = GameObject.FindGameObjectsWithTag("Floor"); foreach (GameObject obj in floor) { GameObject.Destroy(obj); } GameObject[] end = GameObject.FindGameObjectsWithTag("Endpoint"); foreach (GameObject obj in end) { GameObject.Destroy(obj); } foreach (Vector3 pos in mapData.CubePos) { GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.tag = "Floor"; cube.name = "C" + pos.x + pos.y + pos.z; // 'C'ube cube.transform.position = pos; } for (int i = 0; i < mapData.SlopePos.Length; i++) { GameObject slope = makeSlope(); Vector3 pos = mapData.SlopePos[i]; slope.tag = "Floor"; slope.name = "S" + pos.x + pos.y + pos.z; // 'S'lope slope.transform.position = pos; slope.transform.rotation = mapData.SlopeRot[i]; } foreach (RotatingObject data in mapData.RotObj) { GameObject obj = GameObject.Find(data.name); if (obj == null) { continue; } Rotating script = obj.AddComponent <Rotating>() as Rotating; script.point = data.point; script.axis = data.axis; script.PlayerRot = data.playerRot; RotateController.getInstance().addRotating(script, data.groupId); } { GameObject player = GameObject.Find("Player"); player.transform.position = new Vector3(mapData.PlayerStart.x, mapData.PlayerStart.y + 1, mapData.PlayerStart.z); // player.GetComponent <MoveCharacter>().Init(); } //关卡终点 { GameObject endpoint = (GameObject)Resources.Load("Prefabs/endpoint"); endpoint.tag = "Endpoint"; endpoint.transform.position = mapData.GameEnd; Object.Instantiate(endpoint); } //升降 { //************************ //ImapData的底层数据结构设计比较糟糕,修改会影响到其他地图,因此可升降平台在此写死 //************************ if (id == 3) { Map03 mapData03 = (Map03)mapData; GameObject movePoint = (GameObject)Resources.Load("Prefabs/movepoint"); movePoint.transform.position = mapData03.MovePoint; Object.Instantiate(movePoint); } } RotateController.getInstance().select(); }
void Start() { FXParticleSystem = new ParticleSystem[FXObject.Length]; for (int i = 0; i < FXParticleSystem.Length; ++i) { FXParticleSystem[i] = FXObject[i].GetComponent<ParticleSystem>(); } characterStats = GetComponent<CharacterStats>(); attackingSpeed = characterStats.AttackingSpeed; GetComponent<SphereCollider>().radius = characterStats.AttackingRange; muzzleBaseRotating = muzzleBase.GetComponent<Rotating>(); muzzleBaseRotating.rotatingSpeed = turningSpeed; target = null; if (game == null) { game = Camera.main.GetComponent<Game>(); } }
public Rotate(Rotating rotating, int id) { this.rotating = rotating; this.id = id; }
/// <summary> /// Set a rotation state /// </summary> /// <param name="rotating">The new rotation state</param> public void Rotate(Rotating rotating) { m_rotating = rotating; }
/// <summary> /// Automatically choose a rotation state /// </summary> public void AutoRotate() { m_rotating = (Rotating)m_random.Next(0, 3); }
void Start() { rotating = gameObject.GetComponent<Rotating> (); walking = gameObject.GetComponent<Walking> (); }
public void SetRotating(Rotating rotating = Rotating.None) { this.rotating = rotating; }
private void Start() { rotating = GetComponent <Rotating>(); normalAngularSpeed = rotating.angularSpeed; }