Beispiel #1
0
    /// <summary>
    /// The function used for dealing damage or healing a unit
    /// </summary>
    /// <param name="intake">A list of Intakes detailing the incoming damage/heal</param>
    public void ApplyIntake(ref List <Intake> intake)
    {
        for (int i = 0; i < intake.Count; i++)
        {
            if (intake[i].intakeType == Intake.IntakeType.DAMAGE)
            {
                float incoming = intake[i].GetModifiedAmmount();
                print("Took " + incoming + " " + intake[i].GetTypeString() + " Damage.");
                float newhp        = currentHealth - incoming;
                float postHitHpPCT = newhp / maxHealth;
                if (preHitHpPCT <= postHitHpPCT)
                {
                    preHitHpPCT = postHitHpPCT; impactChangeTimer = impactChangeDelay;
                }

                currentHealth = newhp;
                //if (currentHealth <= 0) Destroy(gameObject);
                //applying invuln
                if (intake[i].intakeClass != Intake.IntakeClass.IGNORE_INVULN && incoming > 0)
                {
                    BuffManager.Invulnerability invuln = new BuffManager.Invulnerability();
                    invuln.startDuration = invulnLength;
                    buffManager.AddBuff(invuln);
                }
            }
            else if (intake[i].intakeType == Intake.IntakeType.HEAL)
            {
                float incoming = intake[i].GetModifiedAmmount();
                print("Took " + incoming + " " + intake[i].GetTypeString() + " Healing.");

                float newhp        = currentHealth - incoming;
                float postHitHpPCT = newhp / maxHealth;
                preHitHpPCT = postHitHpPCT;
                if (currentHealth > maxHealth)
                {
                    currentHealth = maxHealth;
                }
                currentHealth = newhp;
                if (currentHealth > maxHealth)
                {
                    currentHealth = maxHealth;
                }
            }
        }
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        float home = Input.GetAxis("ControllerSelect");

        if (home > 0.1f)
        {
            Destroy(GameObject.FindGameObjectWithTag("PlayerRoot"));
            Destroy(GameObject.FindGameObjectWithTag("MainCamera"));
            Destroy(GameObject.FindGameObjectWithTag("HUDCanvas"));
            Destroy(GameObject.FindGameObjectWithTag("JSONManager"));
            UnityEngine.SceneManagement.SceneManager.LoadScene("testscene");
            return;
        }

        if (!ig)
        {
            ig = ctm.weaponHand.transform.GetComponentInChildren <IntakeGenerator>();
        }

        AnimatorStateInfo animState = anim.GetCurrentAnimatorStateInfo(0);

        var camera  = Camera.main;
        var forward = camera.transform.forward;
        var right   = camera.transform.right;

        forward.y = 0f;
        right.y   = 0f;
        forward.Normalize();
        right.Normalize();

        //Character Movement
        //getting input from controller left stick
        inputH = Input.GetAxis("LeftStickHorizontal");
        inputV = Input.GetAxis("LeftStickVertical");
        Vector2 input = new Vector2(inputH, inputV);

        if (input.magnitude < 0.1f)
        {
            inputH = inputV = 0;
        }
        attacc = Input.GetButtonDown("Fire3");//get x button press
        //attackPressTimer -= Time.deltaTime;
        //if (attacc)
        //    attackPressTimer = 1;
        //if (attackPressTimer < 0)
        //    attacc = false;
        //else
        //    attacc = true;

        rollyPolly = Input.GetButtonDown("Fire2"); // get b button press

        if (attacc)
        {
            if (attaccPhase < 3)
            {
                attaccPhase++;
            }
            else
            {
                attaccPhase = 1;
            }
        }


        //animator setting values
        anim.SetFloat("inputH", inputH);
        anim.SetFloat("inputV", inputV);
        anim.SetBool("attacc", attacc);
        anim.SetInteger("attaccPhase", attaccPhase);
        anim.SetBool("rollyPolly", rollyPolly);

        //print(anim.GetCurrentAnimatorStateInfo(0).tagHash);

        //invuln on roll
        if (animState.tagHash == -1061482972)
        {
            BuffManager.Invulnerability invuln = new BuffManager.Invulnerability();
            invuln.startDuration = 0.1f;
            bm.AddBuff(invuln);
        }

        //enable the swords intake (do damage)
        if (animState.tagHash == 1080829965)
        {
            ig.active = true;
        }
        else
        {
            ig.active = false;
        }


        Vector3 desiredMoveDir = -forward * inputV + right * inputH;

        if (desiredMoveDir.magnitude >= 0.3f)
        {
            transform.forward = desiredMoveDir.normalized;
        }

        transform.position += (desiredMoveDir * player_Speed * Time.deltaTime);

        //rbody movement
        // rbody.velocity = new Vector3(inputH *player_Speed * Time.deltaTime, 0.0f, inputV * -player_Speed * Time.deltaTime);
        //rotate char
        //transform.Rotate(0, Input.GetAxis("RightJoystickHorizontal") * DegreesPerSecond, 0);
        //lastAnim = animState;
    }