Exemplo n.º 1
0
    // Use to process your families.
    protected override void onProcess(int familiesUpdateCount)
    {
        foreach (GameObject go in _Damagers)
        {
            // Decrease cooldown
            Damager damager = go.GetComponent <Damager>();
            damager.cooldown -= Time.deltaTime;

            // Can the damager attack ?
            if (damager.cooldown > 0)
            {
                continue;
            }

            // It does, so check if it can hit something
            InCollision3D collider = go.GetComponent <InCollision3D>();
            if (collider.Targets.Length == 0)
            {
                continue;
            }

            // Something is in collision, can we damage it ?
            GameObject target   = collider.Targets[0];
            WithHealth targetWH = target.GetComponent <WithHealth>();
            int        i        = 1;

            while (i < collider.Targets.Length && targetWH == null)
            {
                target   = collider.Targets[i];
                targetWH = target.GetComponent <WithHealth>();
                ++i;
            }
            if (i == collider.Targets.Length)
            {
                continue;
            }

            // We can ! Hit and reset cooldown
            targetWH.health -= damager.damagesPerSec;
            if (targetWH.health <= 0)
            {
                GameObjectManager.addComponent <Removed>(target);
            }
            damager.cooldown = 1;
        }
    }
Exemplo n.º 2
0
    // Use to process your families.
    protected override void onProcess(int familiesUpdateCount)
    {
        foreach (GameObject go in _Eaters)
        {
            InCollision3D collision = go.GetComponent <InCollision3D>();
            Eater         eater     = go.GetComponent <Eater>();

            foreach (GameObject target in collision.Targets)
            {
                Eatable eatable = target.GetComponent <Eatable>();
                if (eatable != null && (eater.eatingMask & eatable.eatableMask) > 0 && Random.value <= eater.eatingProbability)
                {
                    GameObjectManager.addComponent <Removed>(target);
                }
            }
        }
    }
Exemplo n.º 3
0
    // Use to process your families.
    protected override void onProcess(int familiesUpdateCount)
    {
        if (bubble_GO != null)
        {
            if (!hintLever)
            {
                // parse all levers near to hero (only hero can produce Triggered3D component thanks to Unity Physics layers)
                if (levers.Count > 0)
                {
                    GameObjectManager.setGameObjectState(bubble_GO, true);
                    TextMesh text = bubble_GO.GetComponentInChildren <TextMesh> ();
                    text.text       = "+2 is written\non theses levers";
                    startDisplaying = Time.timeSinceLevelLoad;
                    hintLever       = true;
                }
            }

            if (!hintBoiler)
            {
                // Check if boiler is near to hero (only hero can produce Triggered3D component thanks to Unity Physics layers)
                Triggered3D triggered = boiler_GO.GetComponent <Triggered3D> ();
                if (triggered != null)
                {
                    GameObjectManager.setGameObjectState(bubble_GO, true);
                    TextMesh text = bubble_GO.GetComponentInChildren <TextMesh> ();
                    text.text       = "Wow a boiler!\nIt is turned off.";
                    startDisplaying = Time.timeSinceLevelLoad;
                    hintBoiler      = true;
                }
            }

            if (!hintDoor)
            {
                // Check if door is near to hero (only hero can produce Triggered3D component thanks to Unity Physics layers)
                Triggered3D triggered = door_GO.GetComponent <Triggered3D> ();
                if (triggered != null)
                {
                    GameObjectManager.setGameObjectState(bubble_GO, true);
                    TextMesh text = bubble_GO.GetComponentInChildren <TextMesh> ();
                    text.text       = "This door is locked\nI need a key!";
                    startDisplaying = Time.timeSinceLevelLoad;
                    hintDoor        = true;
                }
            }

            if (!hintIceWall && iceWall_GO.GetComponent <BoxCollider> ().enabled)
            {
                InCollision3D collision = iceWall_GO.GetComponent <InCollision3D> ();
                if (collision != null)
                {
                    foreach (GameObject target in collision.Targets)
                    {
                        if (target == hero_GO)
                        {
                            GameObjectManager.setGameObjectState(bubble_GO, true);
                            TextMesh text = bubble_GO.GetComponentInChildren <TextMesh> ();
                            text.text       = "Damn! The path\nis blocked by an\nice wall!";
                            startDisplaying = Time.timeSinceLevelLoad;
                            hintIceWall     = true;
                        }
                    }
                }
            }

            if (!hintKey || !hintMatchstick)
            {
                // Parse all active GO takable in game and near to player (only hero can produce Triggered3D component thanks to Unity Physics layers)
                foreach (GameObject go in inGameObjects)
                {
                    if (!hintKey && go.name == "Key")
                    {
                        GameObjectManager.setGameObjectState(bubble_GO, true);
                        TextMesh text = bubble_GO.GetComponentInChildren <TextMesh> ();
                        text.text       = "A key, It can\nbe useful!";
                        startDisplaying = Time.timeSinceLevelLoad;
                        hintKey         = true;
                    }
                    if (!hintMatchstick && go.name == "Matchstick")
                    {
                        GameObjectManager.setGameObjectState(bubble_GO, true);
                        TextMesh text = bubble_GO.GetComponentInChildren <TextMesh> ();
                        text.text       = "Some matchsticks:\nuseful to make\na fire!";
                        startDisplaying = Time.timeSinceLevelLoad;
                        hintMatchstick  = true;
                    }
                }
            }

            if (bubble_GO.activeSelf && startDisplaying + 4 < Time.timeSinceLevelLoad)
            {
                GameObjectManager.setGameObjectState(bubble_GO, false);
            }
        }
    }