public Player(KinectManager kinect, MouseController mouse, ContentManager content, SlingShot slingshot) { this.kinect = kinect; this.mouse = mouse; this.slingshot = slingshot; texture = content.Load <Texture2D>("Player"); sprite = new Sprite(new Rectangle(texture.Width * 2, (slingshot.GetSprite.GetBounds.Y + slingshot.GetSprite.GetBounds.Height) - texture.Height, texture.Width, texture.Height), texture); //Store the radius of the player for collision detection if (sprite.GetBounds.Width > sprite.GetBounds.Height) { radius = sprite.GetBounds.Width + 2; } else { radius = sprite.GetBounds.Height + 2; } //Calculate the corners of the player CalcCorners(); //Set up particle engine List <Texture2D> textures = new List <Texture2D>(); textures.Add(content.Load <Texture2D>("circle")); textures.Add(content.Load <Texture2D>("star")); textures.Add(content.Load <Texture2D>("diamond")); particleEngine = new ParticleEngine(textures, new Vector2(400, 240)); }
void Start() { initialColorType = colorType; parentObject = transform.parent.gameObject; parentSlingShot = parentObject.GetComponent <SlingShot>(); circleCollider2D = GetComponent <CircleCollider2D>(); spriteRenderer = GetComponent <SpriteRenderer>(); trailRenderer = GetComponent <TrailRenderer>(); rb = GetComponent <Rigidbody2D>(); sj = GetComponent <SpringJoint2D>(); sj.connectedAnchor = parentSlingShot.hook.localPosition; sj.connectedBody = parentObject.GetComponent <Rigidbody2D>(); hookRb = sj.connectedBody; releaseDelay = 1 / (sj.frequency * 4); circleCollider2D.isTrigger = true; PowerUpManager.instance.OnRainbowBallActive += TurnOnRainbowBall; PowerUpManager.instance.OnRainbowBallDeactive += TurnOffRainbowBall; if (PowerUpManager.instance.isRainbowBallActive) { TurnOnRainbowBall(); colorType = ColorType.Rainbow; } }
public void Die() { GameManager.Instance.Lose(); SlingShot sling = GetComponent <SlingShot>(); sling.ResetSlingMode(); sling.PlayerAnimator.SetBool("Aiming", false); }
void Awake() { S = this; Transform launchPointTrans = transform.FindChild ("LaunchPoint"); launchPoint = launchPointTrans.gameObject; launchPoint.SetActive(false); launchPos = launchPointTrans.position; }
void Awake() { S = this; launchPoint = GameObject.Find("LaunchPoint"); launchPoint.SetActive(false); launchPos = launchPoint.transform.position; print(launchPos); }
//********************************************* void Awake() { S = this; Transform launchPointTrans = transform.Find("LaunchPoint"); launchPoint = launchPointTrans.gameObject; launchPoint.SetActive(false); // b launchPos = launchPointTrans.position; }
private Vector3 launchPos; //This is the starting point of the shot void Awake() { S = this; launchPoint = transform.Find("LaunchPoint").gameObject; //sets the halo launchPoint.SetActive(false); //turns the halo off launchPos = launchPoint.transform.position; }
private GameObject shot; //this is the shot object #endregion Fields #region Methods void Awake() { S = this; launchPoint = transform.Find ("LaunchPoint").gameObject; //sets the halo launchPoint.SetActive (false); //turns the halo off launchPos = launchPoint.transform.position; }
private void Awake() { // 设置SlingShot的单例对象S S = this; Transform launchPointTrans = transform.Find("LaunchPoint"); launchPoint = launchPointTrans.gameObject; launchPoint.SetActive(false); launchPos = launchPointTrans.position; }
private void Start() { audio.Play(); rigidbody = GetComponent <Rigidbody2D>(); player = GameObject.FindObjectOfType <SlingShot>(); if (player != null) { movementDirection = (player.transform.position - transform.position).normalized * moveSpeed; } rigidbody.velocity = new Vector2(movementDirection.x, movementDirection.y); Destroy(gameObject, 3.5f); Invoke("PlayDeathSound", 3.3f); Invoke("PlayDeathEffect", 3.45f); }
/// <summary> /// Initialize the world and set up the game /// </summary> public void Initialize(string path) { //Create the controllers kinect = new KinectManager(gameHeight); mouse = new MouseController(); keyboard = new KeyController(); //Make sure there is a Kinect connected if (!kinect.Initialize()) { Console.WriteLine("No Kinect Sensor Connected!"); Environment.Exit(0); } //Load the map and retrieve the dimensions map = new Map(); map.LoadLevel(@"Levels\" + path + ".txt", content); gameHeight = map.GameDimensions[0]; gameWidth = map.GameDimensions[1]; kinect.GameHeight = gameHeight; //Create the objects and set up the world slingshot = new SlingShot(content, kinect, gameHeight); map.SetSlingShot = slingshot; player = new Player(kinect, mouse, content, slingshot); map.SetPlayer = player; slingshot.PlayerPos = player.GetSprite.GetPosition; pointer = new Pointer(content, kinect, mouse); //Create the Pause Button font = content.Load <SpriteFont>("pauseFont"); SpriteFont buttonFont = content.Load <SpriteFont>("buttonFont"); string output = "Play"; Vector2 textSize = buttonFont.MeasureString(output); unPause = new Button(new Vector2((screenWidth * 0.5f) - (textSize.X * 0.5f), screenHeight * 0.5f + textSize.Y), output, buttonFont, content, pointer); output = "Return To Menu"; textSize = buttonFont.MeasureString(output); returnToMenu = new Button(new Vector2((screenWidth * 0.5f) - (textSize.X * 0.5f), unPause.GetSprite.GetPosition.Y + 50), output, buttonFont, content, pointer); //Set up the background Texture2D bg = content.Load <Texture2D>("Background"); Background = new Sprite(new Rectangle(0, 0, bg.Width, screenHeight), bg); //Set up the designer & menu levelDesigner = new Designer(kinect, content, pointer, screenWidth, screenHeight); menu = new Menu(content, pointer, screenWidth, screenHeight, this); // Set up all of your camera options //Set the bounding rectangle around the whole World cam.SetLimits(new Rectangle(0, 0, gameWidth, gameHeight)); //Set the maximum factor to zoom in by, 3.0 is the default cam.SetZoom(1.0f); cam.SetMaxZoom(4.0f); //Set the starting World position of the camera, The below code sets it to the exact centre of the default screen size cam.SetPosition(player.GetSprite.GetPosition); //Set the origin of the camera, typically is the starting position of the camera cam.SetOrigin(cam.GetPosition()); //centre the camera on the player cam.LookAt(player.GetSprite.GetBounds); //If the game is reseting if (worldState == States.reset) { //Start the game worldState = States.play; } }
void Start() { SS = GameObject.Find("slingshot").GetComponent <SlingShot>(); defaulPos = new Vector3(0, 0, 0); transform.position = defaulPos; }
void Start() { slingShot = GetComponent<SlingShot>(); }
void Start() { SS = GameObject.Find("slingshot").GetComponent <SlingShot>(); CreatePoints(); }