// Update is called once per frame void Update() { if (forceFullscreen) { Screen.fullScreen = true; if (Screen.fullScreen) { forceFullscreen = false; } } if (player == null) { player = GameObject.FindGameObjectWithTag("Player").GetComponent <SuperActor>(); } if (!locked) { switch (CameraMoveType) { case CameraType.HorizontalRail: pos = new Vector3(player.transform.position.x, Cameraheight, -100f); pos.x = Mathf.Clamp(pos.x, LeftWall + 320, RightWall - 320); break; case CameraType.VerticalRail: pos = new Vector3(Camerahorizontal, player.transform.position.y + Offset.y, -100f); pos.y = Mathf.Clamp(pos.y, Floor + 180, Roof - 180); break; case CameraType.Free: pos = new Vector3(player.transform.position.x + Offset.x, player.transform.position.y + Offset.y, -100f); break; default: break; } transform.position = pos; } if (Input.GetKeyDown(KeyCode.LeftBracket)) { scale--; if (scale < 1) { scale = 1; } Vector2 newRes = baseRes * scale; ActorManager.instance.scale = scale; Screen.SetResolution((int)newRes.x, (int)newRes.y, FullScreenMode.Windowed, 250); } if (Input.GetKeyDown(KeyCode.RightBracket)) { scale++; Vector2 newRes = baseRes * scale; ActorManager.instance.scale = scale; Screen.SetResolution((int)newRes.x, (int)newRes.y, FullScreenMode.Windowed, 250); } first = false; }
// Use this for initialization void Start() { _actor = GetComponent <SuperActor>(); //The end position is 250 pix to the right of the starting position start = transform.position; end = new Vector2(transform.position.x + 500, 0f); }
public void shoot(Vector2 velocity) { vel = velocity; beenShot = true; platform = Instantiate(movingPlatform, transform.position, Quaternion.identity).GetComponent <SuperActor>(); if (vel.x < 0) { float rot; rot = smoke.GetComponent <ParticleSystem>().shape.rotation.y; rot = 90f; } }
public BombParameters _parameters; // set in unity editor // Use this for initialization void Start() { bombSprites = Resources.LoadAll <Sprite>("Sprites/SunrealBomb"); _actor = GetComponent <SuperActor>(); _spriteRenderer = GetComponent <SpriteRenderer>(); throwable = GetComponent <Throwable>(); time = 0; aniSpeed = 2F; exploded = false; defaultmask = _actor.Parameters.layerMask; _actor.Parameters.layerMask = LayerMask.NameToLayer("Intangible"); gameObject.layer = LayerMask.NameToLayer("Intangible"); }
// Use this for initialization void Start() { state = starState.Spawning; _actor = GetComponent <SuperActor>(); animator = GetComponent <Animator>(); _actor.Active = false; animator.Play("Spawning"); defaultmask = _actor.Parameters.layerMask; _actor.Parameters.layerMask = LayerMask.NameToLayer("Intangible"); gameObject.layer = LayerMask.NameToLayer("Intangible"); Player = GameObject.FindGameObjectWithTag("Player"); throwable = GetComponent <Throwable>(); timePassed = 0; source = GetComponent <AudioSource>(); source.Play(); }
void Start() { superActor = GetComponentInChildren <SuperActor>(); barrierActor = GetComponentInChildren <BarrierActor>(); //barrierActor = GetComponentInChildren<BarrierActor>(); //Initialize appropriate components animator = GetComponent <Animator>(); noOfClicks = 0; canClick = true; UIManager.instance.super.fillAmount = 0; cooldown = 0; UIManager.instance.dash.fillAmount = 0; dashcd = 0; UIManager.instance.reflect.fillAmount = 0; barriorcd = 0; }
// Use this for initialization void Start() { if (player == null) { player = GameObject.FindGameObjectWithTag("Player").GetComponent <SuperActor>(); } if (Screen.fullScreen) { forceFullscreen = true; Screen.SetResolution((int)baseRes.x, (int)baseRes.y, FullScreenMode.ExclusiveFullScreen, 150); } else { Screen.SetResolution((int)baseRes.x, (int)baseRes.y, FullScreenMode.Windowed, 150); } setScale(ActorManager.instance.scale); transform.position = new Vector2(Camerahorizontal, Cameraheight); //setCameraTwo(ActorManager.instance.checkPoint.cameraSettings, player.transform.position); }
// Use this for initialization void Start() { actor = GetComponent <SuperActor>(); }
// Update is called once per frame void Update() { DpadButtons.GetDpad(); if (player._ControllerState.IsCollidingUp && !collideUpPlaying) { ActorManager.instance.PlaySound("Land", 1f); collideUpPlaying = true; } if (player._ControllerState.IsGrounded && !wasGrounded) { collideUpPlaying = false; if (CactiParameters.JumpRestrictions == CactimanParameters.JumpBehavior.CanJumpAnywhereOnce) { CactiParameters.JumpRestrictions = CactimanParameters.JumpBehavior.CanJumpOnGround; } ActorManager.instance.PlaySound("Land", 1f); } if (!player._ControllerState.isStarRiding) { timeOnStar = 0f; } else { timeOnStar += Time.deltaTime; } if (State == CactimanParameters.PlayerState.Dead) { GO_PlayerSprite.GetComponent <Animator>().Play("Die"); gameObject.layer = LayerMask.NameToLayer("Intangible"); player.Active = false; switch (holdType) { case holdObjectType.Nothing: break; case holdObjectType.Bomb: heldObject.GetComponent <Bomb>().removeBomb(); break; case holdObjectType.Star: heldObject.GetComponent <SuperActor>().Remove(); break; default: break; } heldObject = null; holdType = holdObjectType.Nothing; } else if (State == CactimanParameters.PlayerState.InDialog) { getDialogInput(); checkSpikes(); } else { GetInput(); checkSpikes(); } wasGrounded = player._ControllerState.IsCollidingDown; }
private void GetInput() { if (player._ControllerState.IsGrounded) { timeInAir = 0f; } else { timeInAir += Time.deltaTime; } bool hasjumped = false; jumpIn -= Time.deltaTime; if (player._ControllerState.IsGrounded && heldObject == null) { if (DpadButtons.firstUp) { RaycastHit2D[] hits = Physics2D.BoxCastAll((Vector2)transform.position + player._Collider.offset, player._Collider.size, 0, Vector2.zero, Mathf.Infinity); if (hits.Length > 0) { bool enterDialog = false; foreach (var item in hits) { if (item.transform.gameObject.GetComponent <PowerPickUp>()) { item.transform.gameObject.GetComponent <PowerPickUp>().pickedUp(); } if (item.transform.gameObject.GetComponent <DialogTrigger>()) { enterDialog = true; State = CactimanParameters.PlayerState.InDialog; DialogBox.transform.parent.transform.position = new Vector2(item.transform.position.x + 65, item.transform.position.y - 380); DialogBox.GetComponent <Animator>().Play("DialogBoxAnim"); item.transform.gameObject.GetComponent <DialogTrigger>().TriggerDialogue(); break; } } if (enterDialog) { return; } } } } if (DpadButtons.firstA && canJump()) { //player.SetVerticalVelocity(CactiParameters.JumpMagnitude); player.Parameters.StarSnap = false; //player.addVerticalVelocity(CactiParameters.JumpMagnitude); jumpIn = CactiParameters.JumpFrequency; player.Parameters.IgnorePlatforms = true; hasjumped = true; Jumping = true; timeJump = 0; ActorManager.instance.PlaySound("JumpFinal", .8f); } if (Jumping) { if (player._ControllerState.IsCollidingUp) { player.Parameters.StarSnap = true; player.Parameters.IgnorePlatforms = false; Jumping = false; } if (DpadButtons.A) { } else { player.Parameters.StarSnap = true; player.Parameters.IgnorePlatforms = false; Jumping = false; } if (player._ControllerState.IsCollidingDown && timeJump > .01f) { player.Parameters.StarSnap = true; player.Parameters.IgnorePlatforms = false; Jumping = false; } if (timeJump > .21f) { player.Parameters.StarSnap = true; player.Parameters.IgnorePlatforms = false; Jumping = false; } } normalizedHorizontal = 0; if (DpadButtons.left && DpadButtons.right) { } else if (DpadButtons.left) { normalizedHorizontal += -1; //If you are dashing and grounded you cant change direction. Dash will change your direction if you are in air if (State == CactimanParameters.PlayerState.FullControll) { player._ControllerState.IsFacingRight = false; } } else if (DpadButtons.right) { normalizedHorizontal += 1; //If you are dashing and grounded you cant change direction. Dash will change your direction if you are in air if (State == CactimanParameters.PlayerState.FullControll) { player._ControllerState.IsFacingRight = true; } } if (timeOnStar != 0 && timeOnStar <= .15f) { normalizedHorizontal = 0; } if (DpadButtons.X && ActorManager.instance.hasStar && holdType == holdObjectType.Nothing) { holdType = holdObjectType.Star; Vector3 pos = new Vector3(transform.position.x - 4, transform.position.y + 9f, transform.position.z + 1f); heldObject = Instantiate(StarPrefab, pos, Quaternion.identity).GetComponentInChildren <SuperActor>(); } if (DpadButtons.Y && ActorManager.instance.hasBomb && holdType == holdObjectType.Nothing) { holdType = holdObjectType.Bomb; Vector3 pos = new Vector3(transform.position.x - 4, transform.position.y + 9f, transform.position.z + 1f); heldObject = Instantiate(BombPrefab, pos, Quaternion.identity).GetComponentInChildren <SuperActor>(); } if (hasjumped) { GO_PlayerSprite.GetComponent <Animator>().Play("Jump"); } else if (normalizedHorizontal != 0 && State == CactimanParameters.PlayerState.FullControll && player._ControllerState.IsGrounded && jumpIn != CactiParameters.JumpFrequency && jumpIn <= CactiParameters.JumpFrequency - .2f) { GO_PlayerSprite.GetComponent <Animator>().Play("Run"); } else if (jumpIn != CactiParameters.JumpFrequency && player._ControllerState.IsGrounded && jumpIn <= CactiParameters.JumpFrequency - .2f) { GO_PlayerSprite.GetComponent <Animator>().Play("Idle"); } if (player._ControllerState.IsFacingRight) { GO_PlayerSprite.GetComponent <SpriteRenderer>().flipX = false; GO_PlayerSprite.transform.position = transform.position; } else { GO_PlayerSprite.GetComponent <SpriteRenderer>().flipX = true; GO_PlayerSprite.transform.position = transform.position + new Vector3(24, 0, 0); } player.SetHorizontalVeloicty(normalizedHorizontal * 150); if (holdType != holdObjectType.Nothing && heldObject != null) { bool buttonReleased = false; switch (holdType) { case holdObjectType.Nothing: //This never happens break; case holdObjectType.Bomb: heldObject.transform.position = new Vector3(transform.position.x - 20, transform.position.y - 2, transform.position.z + 1); if (DpadButtons.Y) { } else { buttonReleased = true; } break; case holdObjectType.Star: heldObject.transform.parent.position = new Vector3(transform.position.x - 4, transform.position.y + 9f, transform.position.z + 1); if (DpadButtons.X) { } else { buttonReleased = true; } break; default: break; } if (!buttonReleased) { timeholdingobject += Time.deltaTime; } else { timeholdingobject = 0f; } if (heldObject.GetComponent <Throwable>().DoneSpawning&& buttonReleased) { //Throwing Vector2 throwVelocity = new Vector2(); if (player._ControllerState.IsFacingRight) { if (DpadButtons.up) { throwVelocity = new Vector2(150, 400); } else if (DpadButtons.down) { throwVelocity = new Vector2(150, -400); } else { throwVelocity = new Vector2(250, 200); } } else { if (DpadButtons.up) { throwVelocity = new Vector2(-150, 400); } else if (DpadButtons.down) { throwVelocity = new Vector2(-150, -400); } else { throwVelocity = new Vector2(-250, 200); } } heldObject.GetComponentInChildren <Throwable>().Throw(throwVelocity); holdType = holdObjectType.Nothing; heldObject = null; } else if (buttonReleased) { //LetGoTooEarly switch (holdType) { case holdObjectType.Nothing: break; case holdObjectType.Bomb: heldObject.GetComponent <Bomb>().removeBomb(); break; case holdObjectType.Star: heldObject.GetComponent <Star>().removeStar(); break; default: break; } heldObject = null; holdType = holdObjectType.Nothing; } } else if (heldObject == null) { holdType = holdObjectType.Nothing; } }