public IEnumerator RespawnPlayerCo() { //Generate Death Particle //Instantiate (DestroyParticle, player.transform.position, player.transform.rotation); //Hide Player player.enabled = false; player.GetComponent <Renderer> ().enabled = false; // Gravity Reset //gravityStore = player.GetComponent<Rigidbody2D>().gravityScale; player.GetComponent <Rigidbody2D>().gravityScale = 0f; player.GetComponent <Rigidbody2D>().velocity = Vector2.zero; // Point Penalty //ScoreManager.AddPoints(-pointPenaltyOnDeath); //Debug Message Debug.Log("Player Respawn"); //Respawn Delay yield return(new WaitForSeconds(respawnDelay)); //Gravity Restore player.GetComponent <Rigidbody2D>().gravityScale = gravityStore; //Match Players transform position player.transform.position = currentCheckPoint.transform.position; //Show Player player.enabled = true; player.GetComponent <Renderer> ().enabled = true; //Spawn Player Instantiate(respawnParticle, currentCheckPoint.transform.position, currentCheckPoint.transform.rotation); }
public override void PowerActionEnter(GameObject player, Controller2D controller) { applyDmg = controller.GetComponent<PlayerStatus>(); if (trapDuration > slowDuration) { if (!used) { used = true; player.rigidbody2D.drag = 0; applyDmg.Frozen(); frozenEffect = (GameObject)Instantiate(Resources.Load("FrozenEffect"), player.transform.position, Quaternion.identity); frozenEffect.GetComponent<FrozenEffect>().player = controller; frozenplayer = controller; currentplayer = player; networkView.RPC("FreezeFollow", RPCMode.Others, Network.player); if(Analytics.Enabled){ GA.API.Design.NewEvent("Times Frozen", player.transform.position); } } } else { player.rigidbody2D.drag = 100f; } }
void Start() { health = controller.GetComponent <HealthController>(); healthText = GameObject.Find("HealthText").GetComponent <Text>(); healthText.text = health.GetHealth() + "/" + health.maxHealth; }
void Start() { focusArea = new FocusArea(target.GetComponent <Collider2D>().bounds, focusAreaSize); }
private void Start() { target = GameObject.FindWithTag("Player").GetComponent <Controller2D>(); focusArea = new FocusArea(target.GetComponent <Collider2D>().bounds, focusAreaSize); }
// Use this for initialization void Start() { statusDisplay = GetComponent <Text>(); inventory = controller.GetComponent <Inventory>(); }
// Update is called once per frame void Update() { if (!isLocalPlayer) { return; } Vector2 input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")); int wallDirX = (controller.collisions.left) ? -1 : 1; if (isAttacking) //Cannot move while attacking { input.x = 0; if (controller.collisions.below) { targetVelocityX = 0; } } if (!isAttacking) //Allow horizontal move while not attacking { targetVelocityX = input.x * moveSpeed; } velocity.x = Mathf.SmoothDamp(velocity.x, targetVelocityX, ref velocityXSmoothing, (controller.collisions.below) ? accelerationTimeGrounded : accelerationTimeAirorne); bool wallSliding = false; if ((controller.collisions.left || controller.collisions.right) && !controller.collisions.below && velocity.y < 0 && controller.GetComponent <Controller2D>().canWallSlide) //If is wall sliding { wallSliding = true; accelerationTimeAirorne = 0.2f; moveSpeed = initialMoveSpeed * 2; moveSpeed *= transform.localScale.x; if (velocity.y < -wallSlideSpeedMax && (controller.GetComponent <Controller2D>().autoWallSlide || velocity.x != 0)) //Set the maximum drop speed when sliding on wall { velocity.y = -wallSlideSpeedMax; } if (timeToWallUnstick > 0) //Give more wall grab time for jump to opposite side { velocityXSmoothing = 0; velocity.x = 0; if (input.x != wallDirX && input.x != 0) { timeToWallUnstick -= Time.deltaTime; } else { timeToWallUnstick = wallStickTime; } } else { timeToWallUnstick = wallStickTime; } } if (controller.collisions.below) //Set physics when not wall sliding { accelerationTimeAirorne = 0; moveSpeed = initialMoveSpeed * transform.localScale.x; } if (controller.collisions.above || controller.collisions.below) //Stop accumulating gravity if is on ground & prevent going up through roof { velocity.y = 0; } if (Input.GetButtonDown("Jump") && !isAttacking && !isDodging) //Jump logic { if (wallSliding && controller.GetComponent <Controller2D>().canWallJump) //Wall jump { //print("wall jump"); if (wallDirX == input.x) //Wall Climb { //print(wallDirX); velocity.x = -wallDirX * wallJumpClimb.x; //print(velocity.x); velocity.y = wallJumpClimb.y; } else if (input.x == 0) //Jump off wall { velocity.x = -wallDirX * wallJumpOff.x; velocity.y = wallJumpOff.y; } else //Jump to opposite direction { //print("else"); velocity.x = -wallDirX * wallLeap.x; //print(velocity.x); velocity.y = wallLeap.y; } } if (controller.collisions.below) //Jump from ground { //print("jump"); velocity.y = jumpVelocity; } else if (!controller.collisions.below && jumpsRemaining > 0 && !wallSliding) //Air jump { velocity.y = jumpVelocity; jumpsRemaining--; } } velocity.y += gravity * Time.deltaTime; controller.Move(velocity * Time.deltaTime); if (wallSliding || controller.collisions.below) //Reset jump times { jumpsRemaining = jumpTimes - 1; } if (Input.GetButtonDown("Fire1") && !isAttacking && !isDodging) //Attack with light saber { //print("attack"); isAttacking = true; attackPrepSession = attackPrep(); StartCoroutine(attackPrepSession); } else if (Input.GetKeyDown(KeyCode.Q) && isAttacking && isAttackPrep) //Cancel attack { StopCoroutine(attackPrepSession); isAttacking = false; CmdChangeColor(0); isAttackPrep = false; } if (Input.GetButtonDown("Fire2") && !isAttacking && !isDodging) //Dodge move { isDodging = true; velocity.y = 0; teleporte.Teleport(aim.aimingDir, dodgeDistance, dodgeCollisionDetectDist); isDodging = false; } }