コード例 #1
0
 void DamageState() //The countdown for the damage invulnerability.
 {
     DamageTime -= Time.deltaTime;
     if (DamageTime <= 0 && PlayerState == Player_States.PlayerStates.Damaged)
     {
         PlayerState = Player_States.PlayerStates.Normal; //Resets player to default state after damage animation is done.
         //DamageEnabled = true; //Player's invulnerability is over.
     }
 }
コード例 #2
0
    /*public GameObject FindNearestEnemy() //Searches all enemies in the scene to find the nearest to the player.
     * {
     *   GameObject[] Gos;
     *   Gos = GameObject.FindGameObjectsWithTag("Enemy"); //Finds all gameobjects tagged "Enemy" in the scene and adds them to the Gos array.
     *   NearestEnemy = null; //Resets the current Nearest enemy in the event that no enemy is detected at all.
     *   float distance = Mathf.Infinity;
     *   Vector3 pos = transform.position; //Player's position at this frame.
     *   foreach (GameObject Enemy in Gos)
     *   {
     *       Vector3 diff = Enemy.transform.position - pos;
     *       float curDist = diff.sqrMagnitude;
     *       if (curDist < distance) //Checks if enemy is closer than previous enemies gone through in the array.
     *       {
     *           NearestEnemy = Enemy;
     *           distance = curDist;
     *       }
     *   }
     *
     *   return NearestEnemy;
     * }*/
    /*public GameObject FindNearestPerch() //Searches for perch point nearest that's in range.
     * {
     *  GameObject[] PerchPoints;
     *  PerchPoints = GameObject.FindGameObjectsWithTag("Perch"); //finds every gameobject tagged as "Perch" in the scene.
     *  NearestPerch = null; //Resets the current nearest in case none are in range at all.
     *  float distance = Mathf.Infinity;
     *  Vector3 pos = transform.position; //Player's position this frame.
     *  foreach (GameObject PerchPoint in PerchPoints)
     *  {
     *      Vector3 diff = PerchPoint.transform.position - pos;
     *      float curDist = diff.sqrMagnitude;
     *      if (curDist < distance) //Narrows down every perch point in the array to the nearest one to the player.
     *      {
     *          //NearestPerch = PerchPoint;
     *          //distance = curDist;
     *          if ((PerchPoint.transform.position.x <= (transform.position.x + PerchDistanceCheck)) && (PerchPoint.transform.position.x >= (transform.position.x - PerchDistanceCheck))) //Checks if the nearest perch point is in range.
     *          {
     *              if ((PerchPoint.transform.position.y <= (transform.position.y + PerchDistanceCheck)) && (PerchPoint.transform.position.y >= (transform.position.y - PerchDistanceCheck)))
     *              {
     *                  NearestPerch = PerchPoint;
     *                  distance = curDist;
     *              }
     *          }
     *      }
     *  }
     *
     *  return NearestPerch;
     * }*/

    public void DamageTaken(int HealthLost) //Public script that is called by anything doing damage when it's currently going to hit the player.
    {
        if (PlayerHealthState != Player_States.PlayerHealthStates.Dead)
        {
            if (DamageEnabled)                       //Checks if player's invulnerable or not.
            {
                HealthScript.HealthLost(HealthLost); //Takes away from current HP in the Health subscript.
                IFramesTimer = DamageInvuln;
                LevelGM.Instance.NoDamage = false;
                DamageTime    = DamageInvuln / 4;
                DamageEnabled = false; //Give player temporary i-frames
                                       //bool HitAnimGo = (HealthScript.DomahdAlive ? true : false); //Checks if Domahd is still out and alive.
                                       //if (HitAnimGo == true) //Plays damage animation for Domahd if it's not dead.
                                       //{
                                       //    DomahdScript.DomahdAnim.SetTrigger("Damaged");
                                       //}
                                       //myAnim.SetTrigger("Hurt");
                                       //myVoiceBox.clip = DamageGrunt;
                                       //myVoiceBox.Play();
                myAnim.SetBool("Hurt", true);
                LevelGM.Instance.ClearMind = false;
                PlayerDebuffState          = Player_States.PlayerDebuffState.Normal;
                //Everything below resets player's states and resets animation booleans and values to cancel out of anything the player is doing while the damage is happening.
                MeleeScript.ResetMeleeState();
                PlayerState   = Player_States.PlayerStates.Damaged;
                ClingToWall   = false;
                myRB.velocity = new Vector2(0, 0);
                myHitBox.SetBool("Crouching", false);
                myAnim.SetBool("Dashing", false);
                myAnim.SetBool("ClearMind", false);
                //myAnim.SetBool("PounceReady", false);
                //myAnim.SetBool("Pounce", false);
                //myAnim.SetBool("Perched", false);
                myRB.constraints            = MovementScript.YContraints[0];
                MovementScript.dashTime     = 0;
                MovementScript.WallJumpTime = 0;
                //CurrentPerch = null;
                //MovementScript.PerchScript = null;
                //PerchToIgnore = null;
                damageSound.Play();
                DamageState(); //Calls the damage state function for the first time.
            }
        }
    }
コード例 #3
0
    // Use this for initialization
    void Start()
    {
        PlayerObj         = this.gameObject;                         //sets the player object
        PlayerState       = Player_States.PlayerStates.Normal;       //sets state to default
        PlayerHealthState = Player_States.PlayerHealthStates.Normal; //sets health state to default.
        // DeadAudioSource.Stop();
        //AudioListener.pause = true;
        // JumpFall.Stop();
        // myVoiceBox.Stop();
        foreach (GameObject gos in OutfitModels)
        {
            gos.SetActive(true);
        }

        switch (Game.current.Progress.CurrentOutfit)
        {
        case Player_States.OutfitSettings.Default:
            myModel          = OutfitModels[0];
            myAnim           = OutfitAnim[0];
            BackspotMain     = Backspot[0];
            LeftSpotMain     = LeftSpot[0];
            RightSpotMain    = RightSpot[0];
            HeadBonePosition = HeadBones[0];

            Destroy(OutfitModels[1]);
            Destroy(OutfitModels[2]);
            Destroy(OutfitModels[3]);
            Destroy(OutfitModels[4]);
            Destroy(OutfitModels[5]);
            break;

        case Player_States.OutfitSettings.Enemy:
            myModel = OutfitModels[1];
            myAnim  = OutfitAnim[1];

            BackspotMain     = Backspot[1];
            LeftSpotMain     = LeftSpot[1];
            RightSpotMain    = RightSpot[1];
            HeadBonePosition = HeadBones[1];

            Destroy(OutfitModels[0]);
            Destroy(OutfitModels[2]);
            Destroy(OutfitModels[3]);
            Destroy(OutfitModels[4]);
            Destroy(OutfitModels[5]);
            break;

        case Player_States.OutfitSettings.Shadow:
            myModel = OutfitModels[2];
            myAnim  = OutfitAnim[2];

            BackspotMain     = Backspot[2];
            LeftSpotMain     = LeftSpot[2];
            RightSpotMain    = RightSpot[2];
            HeadBonePosition = HeadBones[2];

            Destroy(OutfitModels[1]);
            Destroy(OutfitModels[0]);
            Destroy(OutfitModels[3]);
            Destroy(OutfitModels[4]);
            Destroy(OutfitModels[5]);
            break;

        case Player_States.OutfitSettings.Enlightened:
            myModel = OutfitModels[3];
            myAnim  = OutfitAnim[3];

            BackspotMain     = Backspot[3];
            LeftSpotMain     = LeftSpot[3];
            RightSpotMain    = RightSpot[3];
            HeadBonePosition = HeadBones[3];

            Destroy(OutfitModels[1]);
            Destroy(OutfitModels[2]);
            Destroy(OutfitModels[0]);
            Destroy(OutfitModels[4]);
            Destroy(OutfitModels[5]);
            break;

        case Player_States.OutfitSettings.Boss:
            myModel = OutfitModels[4];
            myAnim  = OutfitAnim[4];

            BackspotMain     = Backspot[4];
            LeftSpotMain     = LeftSpot[4];
            RightSpotMain    = RightSpot[4];
            HeadBonePosition = HeadBones[4];

            Destroy(OutfitModels[1]);
            Destroy(OutfitModels[2]);
            Destroy(OutfitModels[3]);
            Destroy(OutfitModels[0]);
            Destroy(OutfitModels[5]);
            break;

        case Player_States.OutfitSettings.Basic:
            myModel = OutfitModels[5];
            myAnim  = OutfitAnim[5];

            BackspotMain     = Backspot[5];
            LeftSpotMain     = LeftSpot[5];
            RightSpotMain    = RightSpot[5];
            HeadBonePosition = HeadBones[5];

            Destroy(OutfitModels[1]);
            Destroy(OutfitModels[2]);
            Destroy(OutfitModels[3]);
            Destroy(OutfitModels[0]);
            Destroy(OutfitModels[4]);
            break;
        }

        myModel.name = "Model";
        BackSword1.transform.parent = BackspotMain.transform;
        //Backsword2.transform.parent = BackspotMain.transform;
        LeftSword.transform.parent   = LeftSpotMain.transform;
        RightSword.transform.parent  = RightSpotMain.transform;
        LeftSword.transform.position = LeftSpotMain.transform.position;

        RightSword.transform.position = RightSpotMain.transform.position;

        myModel.transform.parent = ParentToModel;

        ClearMindOverlay.SetActive(false);
        DashEffect.SetActive(false);
        ClearMindOverused = false;
        if (Game.current.Progress.Sword1 != Player_States.SwordsObtainedStatus.NotReached && Game.current.Progress.ClearMindLevel == Player_States.ClearMindUpgrade.NotReached)
        {
            ClearMindOverused = true;
        }
        if (LevelGM.Instance.RespawnSFXCanPlay)
        {
            ReviveSFX.Play();
        }
        //SmokeTrail.Stop();
        //if (SmokeTrail != null)
        //{
        //    if (ClingToWall)
        //    {
        //        SmokeTrail.Play();
        //    }
        //    else
        //   {
        //       SmokeTrail.Stop();
        //   }
        // }
        // DamageInvuln = DamageAnimation.length/4; //Sets the DamageInvuln float to the length of the referenced animation clip. Overrides whatever float was put in in inspector
    }