public void Pop(BalloonBehaviour target)
    {
        int index = attachedObjects.IndexOf(target);

        if (index > -1)
        {
            Pop(index);
        }
    }
Exemple #2
0
    void OnTriggerStay2D(Collider2D coll)
    {
        BalloonBehaviour Balloon = coll.GetComponent <BalloonBehaviour>();

        if (Balloon)
        {
            Balloon.addHeat(HeatPerSec * distanceEffectiveness(coll.transform.position) * Time.fixedDeltaTime);
        }
    }
Exemple #3
0
    // Update is called once per frame
    void Update()
    {
        // Don't receive player input unless game is on.
        if (GameManager.instance.levelState != GameManager.LevelState.inGame)
        {
            return;
        }
        if (Time.timeScale == 0f)
        {
            return;                      // Ignore all clicks when paused.
        }
        // Get a target to control.
        BalloonBehaviour balloon = GetClosestTarget(targetCamera.ScreenToWorldPoint(Input.mousePosition));

        if (!balloon)
        {
            return;
        }

        // Process clicking and unclicking.
        if (Input.GetMouseButtonDown(0))
        {
            // Register click, but also limit length of clicks.
            if (clicks.Count == CLICK_LIST_LENGTH)
            {
                clicks.RemoveAt(0);
            }
            clicks.Add(new Click {
                startTime = Time.time
            });

            // Perform different actions depending on whether we have a double click.
            if (HasDoubleClick() && lastControlledItem == balloon)
            {
                if (balloon.cargo)
                {
                    balloon.cargo.Pop(balloon);
                }
                else
                {
                    balloon.Death();
                }
            }
            else
            {
                balloon.Inflate(true);
                lastControlledItem = balloon;
            }
        }
        else if (Input.GetMouseButtonUp(0))
        {
            // Process unclicking.
            if (clicks.Count > 0)
            {
                clicks[clicks.Count - 1].isActive = false;
            }

            // Orders the balloon to stop inflating.
            if (lastControlledItem)
            {
                lastControlledItem.Inflate(false);
            }
        }

        // Update the current click duration if any.
        if (clicks.Count > 0)
        {
            if (clicks[clicks.Count - 1].isActive)
            {
                clicks[clicks.Count - 1].duration += Time.deltaTime;
            }
        }
    }