CharacterBehavior.Update C# (CSharp) Method

Update() public method

public Update ( ) : void
return void
    public override void Update()
    {
        // new fall death code
        if (onGround ()) {
            float newGround = transform.position.y;
            if (fallCheck - 10 > newGround && !Dying) {
                CharacterBehavior.Dying = true;
                PlayerAnim.SetBool ("FallDeath", true);
            }
            fallCheck = newGround;
        }

        if (Dying) {
            transform.GetChild (4).gameObject.SetActive (true);
        }
        if (Input.GetKeyDown(KeyManagerScript.keys["AltJump"]) && !Input.GetKeyDown(KeyManagerScript.keys["Jump"]) || Input.GetKeyDown(KeyManagerScript.keys["Jump"]) && !Input.GetKeyDown(KeyManagerScript.keys["AltJump"]))
        {
            if (onGround())
            {
                rb.AddForce(new Vector2(0, jumpspeed), ForceMode2D.Impulse);
                PlayerAnim.SetBool("Jump", true);
            }
        }
        base.Update ();
        //foreach (Transform t in GroundedEnds)
        //{
        //    //Debug.DrawLine(this.transform.position, t.position, Color.green);
        //}

        checkWall.origin = transform.position;
        rayhit = Physics2D.BoxCast(new Vector3(transform.position.x, transform.position.y + .5f, transform.position.z), BoxVec, 0.0f, checkWall.direction, checkWallDist, wallMasks);
        feet_check = Physics2D.Raycast(new Vector2(checkWall.origin.x , checkWall.origin.y - 1.2f), checkWall.direction, checkWallDist,checkMasks);
        //Debug.DrawRay(checkWall.origin,checkWall.direction,Color.green);
        //Debug.DrawRay(new Vector2(checkWall.origin.x , checkWall.origin.y - 1.2f), checkWall.direction);
        if (feet_check.collider != null)
        {
            //Debug.Log(feet_check.point);
            //Debug.Log(feet_check.collider.gameObject.transform.position.y);
            if (feet_check.collider.gameObject.tag != "impTrigger" && !(Input.GetKey(climb) || Input.GetKey(KeyManagerScript.keys["PushImp"])))
            {
                RaycastHit2D check_empty = Physics2D.Raycast(checkWall.origin, checkWall.direction, checkWallDist, checkMasks);
                if (check_empty.collider == null && Mathf.Abs(Input.GetAxis("Horizontal")) > .5f)
                {
                    //RaycastHit2D newLoc = Physics2D.Raycast(
                    transform.position = new Vector3(transform.position.x, transform.position.y + .3f);
                }
            }
        }
        // Code for holding and throwing imps
        if (HoldingImp!="")
        {
            if(transform.childCount > 4)
            {
                Ray ray = ImpThrowCam.ScreenPointToRay(Input.mousePosition);
                mP = new Ray2D (new Vector2 (ray.origin.x, ray.origin.y-2.5f), new Vector2 (ray.direction.x, ray.direction.y));
                if(Physics2D.Raycast (mP.origin,mP.direction,3.0f,IgnorePlayerLayer).collider == null)
                {
                    transform.GetChild(5).transform.position = new Vector3(mP.GetPoint (2.0f).x,mP.GetPoint (2.0f).y,0.0f);
                }
                else
                {
                    if (!transform.GetChild(5).GetComponent<ImpAI>().dead)
                    {
                        float Change = Physics2D.Raycast(mP.origin, mP.direction, 1.0f, IgnorePlayerLayer).distance;
                        transform.GetChild(5).transform.position = new Vector3(mP.GetPoint(Change - 0.5f).x, mP.GetPoint(Change - 0.5f).y, 0.0f);
                    }
                    else
                    {
                        float Change = Physics2D.Raycast(mP.origin, mP.direction, 1.0f, IgnorePlayerLayer).distance;
                        transform.GetChild(5).transform.position = new Vector3(mP.GetPoint(Change - 0.5f).x, mP.GetPoint(Change - 0.5f).y, 0.0f);
                    }

                }
            }
            else
            {
                HoldingImp = "";
            }
        }

        if (HoldingImp != "" && transform.GetChild(transform.childCount - 1).GetComponent<ImpAI>().DropKill == true)
        {

            HoldingImp = "";
            Throwing = 0.01f;

        }

        // Code for recieving button input
        if ((Input.GetKeyDown (Summon) || Input.GetKeyDown(KeyManagerScript.keys["Summon"])) && (Input.GetKey(modifier) || Input.GetKey(KeyManagerScript.keys["Mod"])) && HoldingImp=="")
        {
            summon(true);
            // Summon a demon
        }
        if ((Input.GetKeyDown(Summon) || Input.GetKeyDown(KeyManagerScript.keys["Summon"])) && !(Input.GetKey(modifier) || Input.GetKey(KeyManagerScript.keys["Mod"])) && HoldingImp == "")
        {
            summon(false);
        }
        if (Input.GetKeyDown (ShiftRight))
        {
            // Cycle the demon selection wheel to the left (NOW REVERSED!)
            if (--selected < 0)
            {
                selected = Demons.Length-1;
            }
            ImpSelect.GetComponent<Image> ().color = Demons [selected].GetComponent<SpriteRenderer> ().color;
        }
        if (Input.GetKeyDown(ShiftLeft) || Input.GetKeyDown(KeyManagerScript.keys["ChangeImp"]))
        {
            // Cycle the demon selection wheel to the right (reversed, CONSIDER REMOVING!)
            if (++selected >= Demons.Length)
            {
                selected = 0;
            }
            ImpSelect.GetComponent<Image> ().color = Demons [selected].GetComponent<SpriteRenderer> ().color;
        }

        if (Input.GetKey(killSelf) || Input.GetKey(KeyManagerScript.keys["KillYourself"]))
        {
            holdDown += Time.deltaTime;
            if (holdDown > 1.0f)
            {
                //OnDeath();
                if (!CharacterBehavior.Dying){
                    PlayerAnim.SetBool("EnemyDeath", true);
                    CharacterBehavior.Dying = true;
                    transform.GetChild (4).gameObject.SetActive (true);
                }
            }
        }
        if (Input.GetKeyUp(killSelf) || Input.GetKeyUp(KeyManagerScript.keys["KillYourself"]))
        {
            holdDown = 0;
        }

        //if (Input.GetKeyDown(KeyCode.U))
        //{
        //    Debug.Log("Imp Deaths");
        //    Debug.Log(ImpsKilled);
        //    Debug.Log("Player Deaths");
        //    Debug.Log(TimesPlayerDied);
        //}

        //Grab an Imp or drop it
        if (Input.GetKeyDown(grabButton))
        {
            if (HoldingImp != "" && HoldingImp != "stickImp")
            {
                HoldingImp = "";
                Throwing = 0.01f;

            }
            else if (HoldingImp != "stickImp")
            {
                summon (true);
            }
        }

        if ((Input.GetMouseButtonDown (0) && !mouseDelay) || Throwing != 0.0f)
        {
            // THROW THE IMP!
            if(HoldingImp!="" && Throwing == 0.0f)
            {
                ThrowImp(ForceMult);
            }
            if(Throwing != 0.0f)
            {
                Throwing = 0.0f;
                if (HoldingImp == "stickImp")
                {
                    transform.GetChild(5).GetComponent<StickImp>().Thrown = true;
                }
                ThrowImp(Throwing);
            }
        }

        if (Input.GetMouseButtonDown(1))
        {
            if (HoldingImp != "")
            {
                Transform heldImp = transform.GetChild(5);
                if (heldImp != null) {
                    ThrowImp (ForceMult);
                    heldImp.GetComponent<ImpAI> ().KillImp ();
                    GrabImp (heldImp.FindChild ("ImpTrigger").GetComponent<BoxCollider2D> ());

                    BoxCollider2D bc = heldImp.GetComponent<ImpAI> ().GetComponent<BoxCollider2D> ();
                    heldImp.GetComponent<ImpAI> ().HalveCollider (bc, heldImp.GetComponent<ImpAI> ().heightChange);
                    bc.offset = new Vector2 (bc.offset.x, bc.offset.y + (heldImp.GetComponent<ImpAI> ().heightChange / 2));
                }
            }
        }

        if (mouseDelay) {
            mouseDelay = false;
        }

        if (Died)
        {
            Died = false;
        }
    }