Exemple #1
0
    /** HAS HYBRID RESULT? **/
    // Given two runes, determines if crossing them produces a hybrid by
    // checking their types. Returns true if so, false otherwise.
    // Also takes the point of intersection to calculate max_reach (if necessary)
    // -- Secondary return values --
    // 1) If h_max_reach is > 0, then this is the maximum reach the hybrid should have.
    //    If is equal to 0, use the default max reach for that type of rune.
    // 2) h_prefab will be set to rune type prefab that the hybrid should be a clone of.
    bool HasHyridResult(Rune r1, Rune r2, Vector2 point, ref float h_max_reach, ref GameObject h_prefab)
    {
        // AIR + AIR => AIR
        if ((r1.type == RuneType.AIR) && (r2.type == RuneType.AIR))
        {
            h_prefab = (GameObject)Resources.Load("Prefabs/Runes/AirRune", typeof(GameObject));

            // Two air runes produce a third air rune with a max reach that is
            // the sum of their remaining lengths
            // (The shorter the two runes, the longer their hybrid)
            h_max_reach  = r1.max_reach - Vector2.Distance(r1.GetPosition(), point);
            h_max_reach += r2.max_reach - Vector2.Distance(r2.GetPosition(), point);

            // If goes nonpositive, default to 0.5
            if (h_max_reach <= 0)
            {
                h_max_reach = 0.5f;
            }

            return(true);
        }

        // WATER + FIRE => STEAM
        if (((r1.type == RuneType.FIRE) && (r2.type == RuneType.WATER)) ||
            ((r2.type == RuneType.FIRE) && (r1.type == RuneType.WATER)))
        {
            h_prefab    = (GameObject)Resources.Load("Prefabs/Runes/SteamRune", typeof(GameObject));
            h_max_reach = 0;
            return(true);
        }

        return(false);
    }
Exemple #2
0
    void FixedUpdate()
    {
        if (inside.Count > 0)
        {
            // Loop through all entities that have entered the effect area
            foreach (PlayerController player in inside)
            {
                // Apply the upward "force" to the velocity to have the appearance of it applying the force
                float distance = Vector2.Distance(player.transform.position, rune.GetPosition());

                // Multiply by the direction of the rune and add to player's velocity
                Vector2 dir = rune.GetVector() * (Force / (Mathf.Pow(distance, .6f)));
                player.velocity.x = dir.x;
                player.velocity.y = dir.y;
            }
        }
    }