public poke(string readIn) //single arg constructor
 {
     name    = readIn;
     ability = "";
     type    = "";
     stats   nums = new stats();
     attacks atks = new attacks();
 }
 public poke() //default constructor
 {
     name    = "null";
     ability = "null";
     type    = "null";
     stats   nums = new stats();
     attacks atks = new attacks();
 }
Example #3
0
    public void Hit(Transform zom, Transform hit, attacks type, Transform impact)
    {
        GetComponent <AudioSource>().PlayOneShot(ImpactSounds[Random.Range(0, ImpactSounds.Length)]);

        if (hit)
        {
            if (HitMode == 0)
            {
                GetComponent <Animation>()[WeaponName + "_fire_01"].speed = -1;
                zom.GetComponent <zombie>().TakeHealth(Damage, impact, "__melee");
            }
            else
            {
                GetComponent <Animation>()[WeaponName + "_fire_02"].speed = -1.25f;
                zom.GetComponent <zombie>().TakeHealth(Damage * 1.75f, impact, "__melee");
            }
        }
        else
        {
            GetComponent <Animation>()[WeaponName + "_fire_01"].speed = -0.5f;
            GetComponent <Animation>()[WeaponName + "_fire_02"].speed = -0.75f;
            //GetComponent.<Animation>().Stop();
        }
    }
Example #4
0
    // Update is called once per frame
    void Update()
    {
        if (mSayTime < Time.time)
        {
            AudioManager.Instance.PlaySoundOnce(mChefComment);
            mSayTime = Time.time + Random.Range(2.5f, 10.0f);
        }
        if (currentState == state.prep && transform.position.x != pos) {
            transform.position = Vector3.MoveTowards(transform.position,new Vector3(pos, transform.position.y, transform.position.z),20*Time.deltaTime);

        }
        else if (currentState == state.prep)
        {
            currentState = state.pick;
        }

        if(currentState == state.pick && Time.time > mCooldown)
        {
            mFirstHit = false;
            mfirstattack = true;
            currentState = state.idel;
            switch ((attacks)UnityEngine.Random.Range(0, (int)attacks.AttackSize))
            {
            case attacks.chop:
                currentAttack = attacks.chop;
                attacktime = Time.time + 1.458f;
                //Destroy( Instantiate(chopWarning,new Vector3(pos,0,0),Quaternion.identity),1.1f);
                Invoke("Chop" ,1f);
                break;
            case attacks.chop1:
                currentAttack = attacks.chop;
                attacktime = Time.time + 1.458f;
                //Destroy( Instantiate(chopWarning,new Vector3(pos,0,0),Quaternion.identity),1.1f);
                Invoke("Chop" ,1f);
                break;
            case attacks.chop2:
                currentAttack = attacks.chop;
                attacktime = Time.time + 1.458f;
                //Destroy( Instantiate(chopWarning,new Vector3(pos,0,0),Quaternion.identity),1.1f);
                Invoke("Chop" ,1f);
                break;
            case attacks.chop3:
                currentAttack = attacks.chop;
                attacktime = Time.time + 1.458f;
                //Destroy( Instantiate(chopWarning,new Vector3(pos,0,0),Quaternion.identity),1.1f);
                Invoke("Chop" ,1f);
                break;
            case attacks.chop4:
                currentAttack = attacks.chop;
                attacktime = Time.time + 1.458f;
                //Destroy( Instantiate(chopWarning,new Vector3(pos,0,0),Quaternion.identity),1.1f);
                Invoke("Chop" ,1f);
                break;
            case attacks.chop5:
                currentAttack = attacks.chop;
                attacktime = Time.time + 1.458f;
                //Destroy( Instantiate(chopWarning,new Vector3(pos,0,0),Quaternion.identity),1.1f);
                Invoke("Chop" ,1f);
                break;
            case attacks.chopShove:
                currentAttack = attacks.chopShove;
                targetPos = (Random.Range(0,2)*2-1);
                attacktime = Time.time + 1.458f;
                Invoke("ChopShove" ,1f);
                break;
            case attacks.Swipeleft:
                currentAttack = attacks.Swipeleft;
                //transform.position = new Vector3(transform.position.x, transform.position.y +1.25f,transform.position.z);
                attacktime = Time.time + 2f;
                Invoke("Swipe" ,1f);
                break;
            case attacks.SwipeRight:
                currentAttack = attacks.SwipeRight;
                attacktime = Time.time + 2f;
                Invoke("Swipe" ,1f);
                break;
            /*case attacks.trippleChop:
                tripchopdir = Random.Range(0,2)*2-1;
                currentAttack = attacks.trippleChop;
                targetPos = (Random.Range(0,2)*2-1);
                Invoke("TrippleChop" ,1f);
                break;*/
            default:
                Debug.LogError("Error currentAttack " + currentAttack);
                break;
            }
        }

        if(currentState == state.execute)
        {
            switch (currentAttack)
            {
            case attacks.chop:
                Chop();
                break;
            case attacks.chopShove:
                ChopShove();
                break;
            case attacks.Swipeleft:
                Swipe();
                break;
            case attacks.SwipeRight:
                Swipe();
                break;
            /*case attacks.trippleChop:
                TrippleChop();
                break;*/
            default:
                Debug.LogError("Error currentAttack " + currentAttack);
                break;
            }
        }

        if(currentState == state.reset)
        {
            if (transform.rotation.eulerAngles.y >= 182 || transform.rotation.eulerAngles.y <= 178) {
                transform.rotation = Quaternion.Euler (0, transform.rotation.eulerAngles.y + -targetPos * 90 * Time.deltaTime, 0);
            }
            else
            {
                transform.rotation = Quaternion.Euler(new Vector3(0,180,0));
                mCooldown = Random.Range(0,1)+ Time.time;
                currentState = state.prep;
                pos = Random.Range(-Limits,Limits+0.1f);
                transform.position = new Vector3(transform.position.x, orgpos,transform.position.z);
            }
        }
    }
 public attackIndex(attacks a, int l)
 {
     attack = a;
     level = l;
 }
    void HandleDirectAttacks()
    {
        //get attacker stats
        float _crit;
        int   _HP      = attacker.GetComponent <stats>().hp;
        int   _attMod  = attacker.GetComponent <stats>().att;
        int   _critmod = attacker.GetComponent <stats>().critmod;
        int   _accMod  = attacker.GetComponent <stats>().acc;

        if (attacker.tag == "ply")
        {
            plyAttacks _attacks = attacker.GetComponent <plyAttacks>();

            _baseAtt  = _attacks.baseDmg;
            _baseCrit = _attacks.basecrit;
        }
        else
        {
            attacks _attacks = attacker.GetComponent <attacks>();

            _baseAtt  = _attacks.baseDmg;
            _baseCrit = _attacks.basecrit;
            _baseAcc  = _attacks.baseacc;
        }


        if (target.GetComponent <isEnemu>())
        {
            // sets the accuracy to be based on what part is being attacked
            switch (target.GetComponent <stats>().bodyPart[attIndex].tag)
            {
            case "head":
                _baseAcc = target.GetComponent <stats>().bodyPart[attIndex].GetComponent <headBehaviour>().baseAcc;
                break;

            case "chest":
                _baseAcc = target.GetComponent <stats>().bodyPart[attIndex].GetComponent <chestBehaviour>().baseAcc;
                break;

            case "arm":
                _baseAcc = target.GetComponent <stats>().bodyPart[attIndex].GetComponent <armBehaviour>().baseAcc;
                break;

            case "leg":
                _baseAcc = target.GetComponent <stats>().bodyPart[attIndex].GetComponent <legBehaviour>().baseAcc;
                break;

            case "hat":
                _baseAcc = target.GetComponent <stats>().bodyPart[attIndex].GetComponent <hatBehaviour>().baseAcc;
                break;

            case "weapon":
                _baseAcc = target.GetComponent <stats>().bodyPart[attIndex].GetComponent <weaponBehaviour>().baseAcc;
                break;
            }
        }

        int _targetArm = target.GetComponent <stats>().armor;


        int _finalAcc = Mathf.Clamp((_baseAcc + (_accMod * 2)), 0, 100);

        int accChance = Random.Range(1, 100);


        if (accChance < _finalAcc)
        {
            if (_baseCrit != 0)
            {
                float _critChance = Mathf.Clamp(((_baseCrit / 100) + 1) * (_critmod + 25), 0, 100);

                int ccRoll = Random.Range(1, 100);
                if (Random.Range(1, 100) <= _critChance)
                {
                    Debug.Log("crit");
                    _crit    = 2f;
                    critAnim = true;
                }
                else
                {
                    _crit    = 1;
                    critAnim = false;
                }
            }
            else
            {
                _crit    = 1;
                critAnim = false;
            }

            int _bonusdmg = (_attMod / 10) * (_baseAtt / 2);
            _dmg = (int)((_baseAtt + _bonusdmg) * (_crit));

            _dmg = Mathf.Clamp((_dmg - _targetArm), 0, 200);

            // damage section

            // damages the part you selected
            if (target.GetComponent <isEnemu>())
            {
                switch (target.GetComponent <stats>().bodyPart[attacker.GetComponent <plyAttacks>().whereInd[hitStep]].tag)
                {
                case "head":
                    Debug.Log("head");
                    target.GetComponent <stats>().bodyPart[attacker.GetComponent <plyAttacks>().whereInd[hitStep]].GetComponent <headBehaviour>().partHP -= _dmg;
                    break;

                case "chest":
                    Debug.Log("chest");
                    target.GetComponent <stats>().bodyPart[attacker.GetComponent <plyAttacks>().whereInd[hitStep]].GetComponent <chestBehaviour>().partHP -= _dmg;

                    break;

                case "arm":
                    Debug.Log("arm");
                    target.GetComponent <stats>().bodyPart[attacker.GetComponent <plyAttacks>().whereInd[hitStep]].GetComponent <armBehaviour>().partHP -= _dmg;

                    break;

                case "leg":
                    Debug.Log("leg");
                    target.GetComponent <stats>().bodyPart[attacker.GetComponent <plyAttacks>().whereInd[hitStep]].GetComponent <legBehaviour>().partHP -= _dmg;

                    break;

                case "hat":
                    Debug.Log("hat");
                    target.GetComponent <stats>().bodyPart[attacker.GetComponent <plyAttacks>().whereInd[hitStep]].GetComponent <hatBehaviour>().partHP -= _dmg;

                    break;

                case "weapon":
                    Debug.Log("weapon");
                    target.GetComponent <stats>().bodyPart[attacker.GetComponent <plyAttacks>().whereInd[hitStep]].GetComponent <weaponBehaviour>().partHP -= _dmg;

                    break;
                }

                target.GetComponent <stats>().hp -= _dmg;
                summonDamage();
            }

            if (target.tag == "ply")
            {
                target.GetComponent <stats>().hp -= _dmg;
            }

            textLog.GetComponent <TextMeshPro>().text = attacker.GetComponent <stats>().name + " hit " + target.name + " for " + _dmg;

            //end of damage section
        }
        else
        {
            textLog.GetComponent <TextMeshPro>().text = attacker.GetComponent <stats>().name + " missed ";
        }
    }
    /************* Start ******************/
    public void Start()
    {
        outageFont = Resources.Load ("Outage") as Font;
        hudInfo = new GameObject();
        hudInfo.AddComponent<Text> ();
        hudInfo.GetComponent<Text> ().font = outageFont;
        hudInfo.transform.SetParent (FindObjectOfType<Canvas> ().transform);

        body = this.GetComponent<CharacterController> ();
        model = this.GetComponentInChildren<Animator>();
        skin = this.GetComponentsInChildren<Renderer>();
        charAttacks = this.GetComponentInChildren<attacks> ();

        health = maxHealth;
        canMove = true;

        lifeState_ = lifeState.STATE_ALIVE;

        maxGravity = -20.0f;
        gravity = maxGravity;
        canDash = true;
        canListen = true;
    }