コード例 #1
0
    void Update()
    {
        Vector2  pos;
        TileNode next = aiMovement.NextNode();

        if (next == null)
        {
            pos = new Vector2(aiMovement.transform.position.x, aiMovement.transform.position.y - 1.0f);
        }
        else
        {
            var size = aiMovement.tileSize;
            pos = new Vector2((float)next.x, -(float)next.y) * size;
        }

        if (Mathf.Abs(transform.position.y - lastYPos) > 0.01f || forceDownCount > 100)
        {
            sidewaysCount  = 0;
            forceDownCount = 0;
        }
        else
        {
            sidewaysCount++;
        }

        lastYPos = transform.position.y;

        if (sidewaysCount > 100)
        {
            forceDownCount++;
            pos = new Vector2(aiMovement.transform.position.x, aiMovement.transform.position.y - 1.0f);
        }

        Vector2 direction = (pos - (Vector2)transform.position).normalized;

        direction.y = Mathf.Clamp(direction.y, -1, 0);

        drillAttackCooldown.Frequency = (1.0f / resources.DrillSpeed) * baseCooldown;

        UpdateDrillRotation(direction);

        if (drillAttackCooldown.Check(Time.time))
        {
            DoDrillAttack(direction);
        }
    }
コード例 #2
0
ファイル: PlayerDrill.cs プロジェクト: sam6321/Tunnels
    void Update()
    {
        Vector2 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        Vector2 direction     = (mousePosition - (Vector2)transform.position).normalized;

        direction.y = Mathf.Clamp(direction.y, -1, 0);

        drillAttackCooldown.Frequency = (1.0f / resources.DrillSpeed) * baseCooldown;

        UpdateDrillRotation(direction);

        bool drillButtonDown = Input.GetButton("Fire1");

        if (drillAttackCooldown.Check(Time.time) && drillButtonDown)
        {
            DoDrillAttack(direction);
        }
    }
コード例 #3
0
ファイル: Fist.cs プロジェクト: DireLines/keywords
 public void Punch(Vector2 dir)
 {
     if (punchCooldown == null)
     {
         punchCooldown = new Cooldown(missCooldownTime);
     }
     if (!punchCooldown.Check())
     {
         return;
     }
     if (gameObject.activeSelf)
     {
         return;
     }
     // fx and stuff
     gameObject.SetActive(true);
     punchCooldown.SetCooldown(missCooldownTime);
     StartCoroutine(ExtendFist(dir));
 }
コード例 #4
0
    private void Update()
    {
        //check cooldown
        speakCD.Check();
        playSoundCD.Check();

        //check position
        if (Vector3.Distance(transform.position, transform.parent.position) > 200)
        {
            ResetPosition();
        }



        //check neighbors
        foreach (GameObject t in ThingManager.main.AllThings)
        {
            float dist = Vector3.Distance(transform.position, t.transform.position);
            if (dist < settings.neighborDetectorRadius)
            {
                if (!neighborList.Contains(t))
                {
                    neighborList.Add(t);
                    OnMeetingSomeone(t);
                }
            }
            else
            {
                if (neighborList.Contains(t))
                {
                    neighborList.Remove(t);
                    OnLeavingSomeone(t);
                }
            }
        }

        TTTUpdate();
    }
コード例 #5
0
 void Update()
 {
     talkCDer.Check();
     sparkCDer.Check();
 }