Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (PS.active)
        {
            if (Input.GetKey(KeyCode.Mouse1) && PS.dead == false)
            {
                WrC.fire = true;
            }
            else
            {
                WrC.fire = false;
            }


            if (WrC.fire == true && Time.time > timeStampR && currentAmmoR > 0 && PS.dead == false)
            {
                timeStampR    = Time.time + WrC.fireRate;
                currentAmmoR -= 1;
                WrC.Atk(BarrelR, AM, true);
            }

            if (((WrC.fire == false && currentAmmoR < WrC.ammo) || currentAmmoR <= 0) && Time.time > ammoTimeStampR)
            {
                ammoTimeStampR = Time.time + WrC.reloadRate;
                currentAmmoR  += 1;
            }
            ammoTextR.text = currentAmmoR.ToString() + "/" + WrC.ammo.ToString();


            if (Input.GetKey(KeyCode.Mouse0) && PS.dead == false)
            {
                WlC.fire = true;
            }
            else
            {
                WlC.fire = false;
            }

            if (HC.type == "blast" && Input.GetKeyDown(KeyCode.LeftShift) && PS.currentEnergy >= HC.cost && PS.dead == false)
            {
                PS.currentEnergy -= HC.cost;
                HC.Special(gameObject.transform, true);
            }


            if (WlC.fire == true && Time.time > timeStampL && currentAmmoL > 0 && PS.dead == false)
            {
                timeStampL    = Time.time + WlC.fireRate;
                currentAmmoL -= 1;
                WlC.Atk(BarrelL, AM, true);
            }

            if (((WlC.fire == false && currentAmmoL < WlC.ammo) || currentAmmoL <= 0) && Time.time > ammoTimeStampL)
            {
                ammoTimeStampL = Time.time + WlC.reloadRate;
                currentAmmoL  += 1;
            }
            ammoTextL.text = currentAmmoL.ToString() + "/" + WlC.ammo.ToString();
        }
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (active)
        {
            if (struck == true)
            {
                struck = false;
                StartCoroutine(showHit());
            }
            if (sideL.hittingWall && !sideR.hittingWall)
            {
                Left  = false;
                Right = true;
            }
            else if (sideR.hittingWall && !sideL.hittingWall)
            {
                Left  = true;
                Right = false;
            }
            else if (sideR.hittingWall && sideL.hittingWall)
            {
                Right = false;
                Left  = false;
            }

            //Armor 8 AI

            //if player not in radar range or IS in range
            //walk towards player


            //if player in viewing range
            //boost towards them
            float distance = Vector3.Distance(transform.position, Player.transform.position);

            if (!dead)
            {
                isBoosting = true;
                if (distance > 30)
                {
                    inCannonRange  = false;
                    inShotGunRange = false;
                    Left           = false;
                    Right          = false;
                }
                else if (distance > shotgunRange)
                {
                    isBoosting     = true;
                    inCannonRange  = true;
                    inShotGunRange = false;
                }
                else if (distance > overrideRange)
                {
                    isBoosting     = true;
                    inCannonRange  = true;
                    inShotGunRange = true;
                }
                else
                {
                    isBoosting      = true;
                    inCannonRange   = true;
                    inShotGunRange  = true;
                    inOverrideRange = true;
                }

                if (inCannonRange == true && Time.time > timeStampR && currentAmmoR > 0)
                {
                    fireRight     = true;
                    timeStampR    = Time.time + WrC.fireRate;
                    currentAmmoR -= 1;
                    WrC.Atk(BarrelR, AM, ally);
                }

                if (((inCannonRange == false && currentAmmoR < WrC.ammo) || currentAmmoR <= 0) && Time.time > ammoTimeStampR)
                {
                    ammoTimeStampR = Time.time + WrC.reloadRate;
                    currentAmmoR  += 1;
                }

                if (inShotGunRange == true && Time.time > timeStampL && currentAmmoL > 0)
                {
                    timeStampL    = Time.time + WlC.fireRate;
                    currentAmmoL -= 1;
                    WlC.Atk(BarrelL, AM, ally);
                }

                if (((inShotGunRange == false && currentAmmoL < WlC.ammo) || currentAmmoL <= 0) && Time.time > ammoTimeStampL)
                {
                    ammoTimeStampL = Time.time + WlC.reloadRate;
                    currentAmmoL  += 1;
                }


                if (inOverrideRange == true && Time.time > timeStampO && currentHP <= maxHP / 2)
                {
                    timeStampO = Time.time + HC.cooldown;
                    //currentAmmoL -= 1;
                    HC.Special(gameObject.transform, ally);
                }



                if (movement != Vector2.zero)
                {
                    Quaternion newRot = Quaternion.LookRotation(Vector3.forward, movement);
                    legsChildren.transform.rotation = newRot;
                    //Debug.Log(legsChildren.transform.localRotation.eulerAngles.z);
                    if (legsChildren.transform.localRotation.eulerAngles.z > 90 && legsChildren.transform.localRotation.eulerAngles.z < 270)
                    {
                        //    newRot = Quaternion.Inverse(newRot);
                        //    //Vector3 rot = legsChildren.transform.localRotation.eulerAngles;
                        //    //rot = new Vector3(newRot.x, newRot.y, newRot.z - 180);
                        legsChildren.transform.localScale = Vector3.down + Vector3.right + Vector3.forward;
                        //    ////rot = new Vector3(rot.x, rot.y, Mathf.Clamp(rot.z, legsChildren.transform.rotation.eulerAngles.z - 90, legsChildren.transform.rotation.eulerAngles.z + 90));
                        //    //newRot = Quaternion.Euler(rot);
                        //legsChildren.transform.rotation = rot180degrees;
                    }
                    else
                    {
                        legsChildren.transform.localScale = Vector3.up + Vector3.right + Vector3.forward;
                    }
                }
                else
                {
                    legsChildren.transform.rotation = transform.rotation;
                }

                if (path == null)
                {
                    return;
                }
                if (currentWaypoint >= path.vectorPath.Count)
                {
                    reachedEndOfPath = true;
                    return;
                }
                else
                {
                    reachedEndOfPath = false;
                }

                //            Vector2 directoin =
                movement = ((Vector2)path.vectorPath[currentWaypoint] - rb.position).normalized; //Vector3.Normalize(Player.transform.position - transform.position);

                float d = Vector2.Distance(rb.position, path.vectorPath[currentWaypoint]);
                if (d < nextWaypointDistance)
                {
                    currentWaypoint++;
                }
            }
            else
            {
                rb.velocity = Vector2.zero;
                if (Boosters.isPlaying)
                {
                    Boosters.Stop();
                }
                Anim.speed = 0;
                movement   = Vector2.zero;
            }

            //if player in shooting range
            //rotate around them and charge towards them
            //shoot the f**k out of them
            //keep a certain distance away

            //if player is really close
            //activate overdrive atk

            //if bullet is near
            //sidestep
            //if missle is near
            //sidestep and charge towards player if near

            //if energy below 20%
            //dont boost unless avoiding a projectile

            //notes: armor 8 is hyper aggressive and tanky, the strategy is to strafe and chagre until in overdrive range, this armor cares very little for their own safety



            //movement.x = Input.GetAxisRaw("Horizontal");
            //movement.y = Input.GetAxisRaw("Vertical");
        }
    }