Esempio n. 1
0
    void Respawn()
    {
        currentState = CasterState.Idle;
        GameObject respawnCaster = Instantiate(thisCaster) as GameObject;

        respawnCaster.transform.position = new Vector3(0, 150, 0);
    }
Esempio n. 2
0
    public virtual void MyRuneWasCounteredCallback()
    {
        // do something here if something extra should happen when ebing countered
        myState = CasterState.stunned;
        anim.Play("Block");
        myRuneWasblockedImage.gameObject.SetActive(true);
        CancelInvoke("EndStun");
        Invoke("EndStun", 1f);

        HideCurrentRuneCallback();
    }
Esempio n. 3
0
    /*
     * void SetHealthText()
     * {
     *
     *  healthText.text = "Health: " + health.ToString();
     * }
     */

    public void TakeDamage(int damageTaken, Vector3 damageDirection)
    {
        //if hit by an attack, send this to health/screen display
        if (!isServer)
        {
            return;
        }

        currentHealth -= damageTaken;
        Debug.Log("You took damage");

        if (currentHealth <= 0)
        {
            currentState = CasterState.Dead;
        }
    }
Esempio n. 4
0
 void Awake()
 {
     myCaster           = GetComponent <CharacterController>();
     anim               = GetComponent <Animator>();
     currentState       = CasterState.Idle;
     targetRotation     = transform.rotation;
     fireball           = Resources.Load("Fireball") as GameObject;
     firewall           = Resources.Load("Firewall") as GameObject;
     crouchToggle       = false;
     sprintToggle       = false;
     fireballReady      = true;
     firewallReady      = true;
     afterburnerReady   = true;
     flareboostersReady = true;
     health             = 100;
 }
Esempio n. 5
0
    public virtual void HitByRune(Rune rune)
    {
        int scaledDmg = Mathf.RoundToInt((float)rune.baseDamage * rune.power);

        _currentHealth = Mathf.Clamp(_currentHealth - scaledDmg, 0, totalHealth);
        healthBar.SetValueCurrent(_currentHealth);

        if (_currentHealth == 0)
        {
            myState = CasterState.dead;
            anim.Play("Die");
        }
        else
        {
            anim.Play("Get_Hit_Front");
        }
    }
Esempio n. 6
0
    void Awake()
    {
        myCaster         = GetComponent <CharacterController>();
        currentState     = CasterState.Idle;
        targetRotation   = transform.rotation;
        moveDirection    = Vector3.zero;
        playerUIinstance = Instantiate(playerUIPrefab);
        currentHealth    = maxHealth;
        moveSpeed        = 10f;

        /*
         * crouchToggle = false;
         * sprintToggle = false;
         * fireballReady = true;
         * firewallReady = true;
         * afterburnerReady = true;
         * flareboostersReady = true;
         */
    }
Esempio n. 7
0
 void EndStun()
 {
     myState = CasterState.ready;
     myRuneWasblockedImage.gameObject.SetActive(false);
 }
Esempio n. 8
0
 void Awake()
 {
     myCaster = GetComponent<CharacterController>();
     anim = GetComponent<Animator>();
     currentState = CasterState.Idle;
     targetRotation = transform.rotation;
     fireball = Resources.Load("Fireball") as GameObject;
     firewall = Resources.Load("Firewall") as GameObject;
     crouchToggle = false;
     sprintToggle = false;
     fireballReady = true;
     firewallReady = true;
     afterburnerReady = true;
     flareboostersReady = true;
     health = 100;
 }
Esempio n. 9
0
    void CurrentStateCalculator()
    {
        //Axis Input
        float h = Input.GetAxis("Horizontal");
        float v = Input.GetAxis("Vertical");
        float mouseX = Input.GetAxis("Mouse X");
        anim.SetFloat("vInput", v);
        anim.SetFloat("hInput", h);
        
        //gravity
        moveDirection.y -= gravity * Time.deltaTime;
        myCaster.Move(moveDirection * Time.deltaTime);

        //turning with mouse
        targetRotation *= Quaternion.AngleAxis(rotSpeed * mouseX * Time.deltaTime, Vector3.up);
        myCaster.transform.rotation = targetRotation;

        if (myCaster.isGrounded)
        {
            if (Input.GetButtonDown("Crouch"))
                CrouchToggle();

            //To Idle & Crouch Idle
            if (v == 0 && h == 0 && crouchToggle == false)
            {
                currentState = CasterState.Idle;
                sprintToggle = false;
                moveDirection = Vector3.zero;
            }
            else if (v == 0 && h == 0 && crouchToggle == true)
            {
                currentState = CasterState.CrouchingIdle;
                sprintToggle = false;
                moveDirection = Vector3.zero;
            }

                //To Walk & Crouch Walk & Sprint
                if (Mathf.Abs(h) > 0 || Mathf.Abs(v) > 0)
            {
                if (Input.GetButtonDown("Sprint"))
                    SprintToggle();

                if (crouchToggle == false)
                {
                    moveDirection = new Vector3(h, 0, v);
                    moveDirection = transform.TransformDirection(moveDirection);
                    moveDirection *= moveSpeed;
                    currentState = CasterState.Walking;
                }
                else if (crouchToggle == true)
                {
                    moveDirection = new Vector3(h, 0, v);
                    moveDirection = transform.TransformDirection(moveDirection);
                    moveDirection *= moveSpeed/2;
                    currentState = CasterState.CrouchWalking;
                }
                if (sprintToggle == true)
                {
                    crouchToggle = false;
                    moveDirection = new Vector3(h, 0, v);
                    moveDirection = transform.TransformDirection(moveDirection);
                    moveDirection *= sprintSpeed;
                    currentState = CasterState.Sprinting;
                }
            }
        }
        AnimationManager();
    }
Esempio n. 10
0
 void Awake()
 {
     myCaster = GetComponent<CharacterController>();
     currentState = CasterState.Idle;
     targetRotation = transform.rotation;
     moveDirection = Vector3.zero;
     playerUIinstance = Instantiate(playerUIPrefab);
     currentHealth = maxHealth;
     moveSpeed = 10f;
     /*
     crouchToggle = false;
     sprintToggle = false;
     fireballReady = true;
     firewallReady = true;
     afterburnerReady = true;
     flareboostersReady = true;
     */
 }
Esempio n. 11
0
 void Respawn()
 {
     currentState = CasterState.Idle;
     GameObject respawnCaster = Instantiate(thisCaster) as GameObject;
     respawnCaster.transform.position = new Vector3(0, 150, 0);
 }
Esempio n. 12
0
    void InputHandler()
    {
        //Axis Input
        float h = Input.GetAxis("Horizontal");
        float v = Input.GetAxis("Vertical");
        float mouseX = Input.GetAxis("Mouse X");

        //turning with mouse
        targetRotation *= Quaternion.AngleAxis(rotSpeed * mouseX * Time.deltaTime, Vector3.up);
        myCaster.transform.rotation = targetRotation;

        if (currentState != CasterState.Dead)
        {
            if (myCaster.isGrounded)
            {
                //To Idle
                if (v == 0 && h == 0)
                {
                    currentState = CasterState.Idle;
                    moveDirection = Vector3.zero;
                }

                //To Move
                if (Mathf.Abs(h) > 0 || Mathf.Abs(v) > 0)
                {
                    if (Mathf.Abs(h) >= .75 && Mathf.Abs(v) >= .75)
                    {
                        if(h >= .75)
                            h = .75f;
                        if (h <= -.75)
                            h = -.75f;
                        if (v >= .75)
                            v = .75f;
                        if (v <= -.75)
                            v = -.75f;
                    }
                    moveDirection = new Vector3(h, 0, v);
                    moveDirection = transform.TransformDirection(moveDirection);
                    moveDirection *= moveSpeed;
                    currentState = CasterState.Walking;
                }
            }
            else
            {
                //gravity
                moveDirection.y -= gravity * Time.deltaTime;
            }
            myCaster.Move(moveDirection * Time.deltaTime);


            //FireballSkill (Mouse1)
            if (Input.GetButtonDown("Attack1"))
            {
                CmdAttack1();
                //Invoke("Attack1", .5f);
            }

            //FireWall (Mouse2)
            if (Input.GetButtonDown("Attack2"))
            {
                Attack2();
                //Invoke("Attack2", 2f);
            }

            //Afterburner (F)
            if (Input.GetButtonDown("MoveSkill"))
            {
                MoveSkill();
            }

            //FlareBoosters (Space)
            if (Input.GetButtonDown("JumpSkill"))
            {
                JumpSkill();
            }
        }
    }
Esempio n. 13
0
    /*
    void SetHealthText()
    {

        healthText.text = "Health: " + health.ToString();
    }
    */

    public void TakeDamage(int damageTaken, Vector3 damageDirection)
    {
        //if hit by an attack, send this to health/screen display
        if (!isServer)
            return;

        currentHealth -= damageTaken;
        Debug.Log("You took damage");

        if (currentHealth <= 0)
        {
            currentState = CasterState.Dead;
        }
    }
Esempio n. 14
0
    void InputHandler()
    {
        //Axis Input
        float h      = Input.GetAxis("Horizontal");
        float v      = Input.GetAxis("Vertical");
        float mouseX = Input.GetAxis("Mouse X");

        //turning with mouse
        targetRotation *= Quaternion.AngleAxis(rotSpeed * mouseX * Time.deltaTime, Vector3.up);
        myCaster.transform.rotation = targetRotation;

        if (currentState != CasterState.Dead)
        {
            if (myCaster.isGrounded)
            {
                //To Idle
                if (v == 0 && h == 0)
                {
                    currentState  = CasterState.Idle;
                    moveDirection = Vector3.zero;
                }

                //To Move
                if (Mathf.Abs(h) > 0 || Mathf.Abs(v) > 0)
                {
                    if (Mathf.Abs(h) >= .75 && Mathf.Abs(v) >= .75)
                    {
                        if (h >= .75)
                        {
                            h = .75f;
                        }
                        if (h <= -.75)
                        {
                            h = -.75f;
                        }
                        if (v >= .75)
                        {
                            v = .75f;
                        }
                        if (v <= -.75)
                        {
                            v = -.75f;
                        }
                    }
                    moveDirection  = new Vector3(h, 0, v);
                    moveDirection  = transform.TransformDirection(moveDirection);
                    moveDirection *= moveSpeed;
                    currentState   = CasterState.Walking;
                }
            }
            else
            {
                //gravity
                moveDirection.y -= gravity * Time.deltaTime;
            }
            myCaster.Move(moveDirection * Time.deltaTime);


            //FireballSkill (Mouse1)
            if (Input.GetButtonDown("Attack1"))
            {
                CmdAttack1();
                //Invoke("Attack1", .5f);
            }

            //FireWall (Mouse2)
            if (Input.GetButtonDown("Attack2"))
            {
                Attack2();
                //Invoke("Attack2", 2f);
            }

            //Afterburner (F)
            if (Input.GetButtonDown("MoveSkill"))
            {
                MoveSkill();
            }

            //FlareBoosters (Space)
            if (Input.GetButtonDown("JumpSkill"))
            {
                JumpSkill();
            }
        }
    }
Esempio n. 15
0
    void CurrentStateCalculator()
    {
        //Axis Input
        float h      = Input.GetAxis("Horizontal");
        float v      = Input.GetAxis("Vertical");
        float mouseX = Input.GetAxis("Mouse X");

        anim.SetFloat("vInput", v);
        anim.SetFloat("hInput", h);

        //gravity
        moveDirection.y -= gravity * Time.deltaTime;
        myCaster.Move(moveDirection * Time.deltaTime);

        //turning with mouse
        targetRotation *= Quaternion.AngleAxis(rotSpeed * mouseX * Time.deltaTime, Vector3.up);
        myCaster.transform.rotation = targetRotation;

        if (myCaster.isGrounded)
        {
            if (Input.GetButtonDown("Crouch"))
            {
                CrouchToggle();
            }

            //To Idle & Crouch Idle
            if (v == 0 && h == 0 && crouchToggle == false)
            {
                currentState  = CasterState.Idle;
                sprintToggle  = false;
                moveDirection = Vector3.zero;
            }
            else if (v == 0 && h == 0 && crouchToggle == true)
            {
                currentState  = CasterState.CrouchingIdle;
                sprintToggle  = false;
                moveDirection = Vector3.zero;
            }

            //To Walk & Crouch Walk & Sprint
            if (Mathf.Abs(h) > 0 || Mathf.Abs(v) > 0)
            {
                if (Input.GetButtonDown("Sprint"))
                {
                    SprintToggle();
                }

                if (crouchToggle == false)
                {
                    moveDirection  = new Vector3(h, 0, v);
                    moveDirection  = transform.TransformDirection(moveDirection);
                    moveDirection *= moveSpeed;
                    currentState   = CasterState.Walking;
                }
                else if (crouchToggle == true)
                {
                    moveDirection  = new Vector3(h, 0, v);
                    moveDirection  = transform.TransformDirection(moveDirection);
                    moveDirection *= moveSpeed / 2;
                    currentState   = CasterState.CrouchWalking;
                }
                if (sprintToggle == true)
                {
                    crouchToggle   = false;
                    moveDirection  = new Vector3(h, 0, v);
                    moveDirection  = transform.TransformDirection(moveDirection);
                    moveDirection *= sprintSpeed;
                    currentState   = CasterState.Sprinting;
                }
            }
        }
        AnimationManager();
    }