void Update()
 {
     if (sc && crit)
     {
         GameObject target = World.GetNearestPlayer(sc);
         if (target != null)
         {
             Vector3 targetPosition = target.GetComponent <SC>().position;
             sc.SetDirectionTo(targetPosition);
             float dist = Vector3.Distance(targetPosition, sc.position);
             if (dist > 1)
             {
                 sc.MoveForward(crit.speed * speedModifier * Time.deltaTime);
             }
             else
             {
                 if (dist < minDist)
                 {
                     sc.MoveForward(-crit.speed * speedModifier * Time.deltaTime);
                 }
                 sc.MoveSide(lovedSideDirection * crit.speed * speedModifier * Time.deltaTime);
             }
             crit.Attack(target.GetComponent <SC>().position);
         }
     }
 }
Example #2
0
 void Update()
 {
     if (sc && crit)
     {
         GameObject target = World.GetNearestPlayer(sc);
         if (target != null)
         {
             if (coolDown <= 0)
             {
                 if (currentTarget.magnitude == 0)
                 {
                     currentTarget = target.GetComponent <SC>().position;
                 }
                 float dist = Vector3.Distance(currentTarget, sc.position);
                 if (dist > 0.1f)
                 {
                     sc.SetDirectionTo(currentTarget);
                     sc.MoveForward(crit.speed * speedModifier * Time.deltaTime);
                     crit.Attack(target.GetComponent <SC>().position);
                 }
                 else
                 {
                     currentTarget.Set(0, 0, 0);
                     coolDown = 1.5f;
                 }
             }
             else
             {
                 coolDown -= Time.deltaTime;
             }
         }
     }
 }
Example #3
0
 void Update()
 {
     if (sc && crit)
     {
         GameObject target = World.GetNearestPlayer(sc);
         if (target != null)
         {
             Vector3 targetPosition = target.GetComponent <SC>().position;
             sc.SetDirectionTo(targetPosition);
             crit.Attack(target.GetComponent <SC>().position);
         }
     }
 }
Example #4
0
 void Update()
 {
     if (sc && crit)
     {
         GameObject target = World.GetNearestPlayer(sc);
         if (target != null)
         {
             sc.SetDirectionTo(target.GetComponent <SC>().position);
             sc.MoveForward(crit.speed * speedModifier * Time.deltaTime);
             crit.Attack(target.GetComponent <SC>().position);
         }
     }
 }
    // Update is called once per frame
    void Update()
    {
        if (sc && critter)
        {
            //change backpack
            if (MoonzInput.GetKeyDown(MoonzInput.ARROW_UP, inputSuffix))
            {
                GetComponent <Eq>().ChangeSlot(Item.SLOT_UP);
            }

            if (MoonzInput.GetKeyDown(MoonzInput.ARROW_DOWN, inputSuffix))
            {
                GetComponent <Eq>().ChangeSlot(Item.SLOT_DOWN);
            }

            if (MoonzInput.GetKeyDown(MoonzInput.ARROW_LEFT, inputSuffix))
            {
                GetComponent <Eq>().ChangeSlot(Item.SLOT_LEFT);
            }

            if (MoonzInput.GetKeyDown(MoonzInput.ARROW_RIGHT, inputSuffix))
            {
                GetComponent <Eq>().ChangeSlot(Item.SLOT_RIGHT);
            }

            if (MoonzInput.GetKeyDown(MoonzInput.B, inputSuffix) && eq.GetShield() != null)
            {
                critter.shieldActive = !critter.shieldActive;
            }
            bubble.SetActive(critter.shieldActive && eq.GetShield() != null);

            if (MoonzInput.GetKeyDown(MoonzInput.A, inputSuffix))
            {
                if (eq.downSlot != null)
                {
                    critter.UseBuff(eq.downSlot);
                    eq.RemoveItem(eq.downSlot.GetComponent <Item>());
                }
            }

            float h = MoonzInput.GetAxis("H", inputSuffix);
            float v = MoonzInput.GetAxis("V", inputSuffix);

            float angle;
            if (Mathf.Abs(h) + Mathf.Abs(v) > 0.5f)
            {
                GetComponent <Animator>().SetInteger("animId", 0);
                angle       = Mathf.Atan2(h, v);
                sp.rotation = Quaternion.Euler(0, angle * 180 / Mathf.PI, 0);
            }
            else
            {
                GetComponent <Animator>().SetInteger("animId", 1);
            }

            sc.MoveForward(v * critter.getSpeed() * Time.deltaTime);
            sc.MoveSide(h * critter.getSpeed() * Time.deltaTime);

            float fh = MoonzInput.GetAxis("FH", inputSuffix);
            float fv = MoonzInput.GetAxis("FV", inputSuffix);
            angle = Mathf.Atan2(fh, fv);

            if (Mathf.Abs(fh) + Mathf.Abs(fv) > 0.5)
            {
                Vector3 shootDirection = Camera.main.transform.up * fv + Camera.main.transform.right * fh;
                critter.Attack(sc.position + shootDirection);
                sp.rotation = Quaternion.Euler(0, angle * 180 / Mathf.PI, 0);
            }

            if (MoonzInput.GetKeyDown(MoonzInput.RB, inputSuffix) || MoonzInput.GetKeyDown(MoonzInput.X, inputSuffix))
            {
                PickDropIfAny();
            }
        }
    }