Пример #1
0
    // Function to move the gameobject "line" (called from update)
    void updateline()
    {
        if (line == null)
        {
            return;
        }
        LineRenderer l = line.GetComponent <LineRenderer>();

        l.positionCount = 2;
        Vector3 oldposition = pressed_star_position;
        Vector3 newposition =
            GameDad.selectedStar == -1?
            reticle.transform.position:
            GameDad.selectedStarLocation;
        bool stillgreen = GameDad.is_green(pressed_star) &&
                          (GameDad.get_green(pressed_star).type == greenstar.Type.Green);

        make_line_red(l, !stillgreen || too_far(newposition - oldposition)); // test
        Vector3[] positions = new Vector3[] {
            0.9f * oldposition + 0.1f * newposition,
            0.2f * oldposition + 0.8f * newposition
        };
        l.SetPositions(positions);
        //Debug.Log(positions[0]);
        //Debug.Log(positions[1]);
    }
Пример #2
0
 public void spamseed_lands_on_star(int ix, Vector3 vector)
 {
     if (GameDad.is_green(ix) && GameDad.get_green(ix).type == greenstar.Type.Green)
     {
         GameDad.remove_green(ix);
         gamedad_make_red(ix, vector, true);
     }
 }
Пример #3
0
 void space_release()
 {
     if (pressed == true)
     {
         pressed = false;
         if (pressed_star != -1)
         {
             // There is a line from a star.
             if (GameDad.is_green(pressed_star) && GameDad.get_green(pressed_star).type == greenstar.Type.Green)
             {
                 // The star is green.
                 if (GameDad.selectedStar != -1)
                 {
                     // The line goes to another star.
                     if (!too_far(pressed_star_position - GameDad.selectedStarLocation))
                     {
                         // The line is not too long.
                         GameDad.linedrawn_hook(pressed_star,
                                                pressed_star_position,
                                                GameDad.selectedStar,
                                                GameDad.selectedStarLocation);
                     }
                 }
             }
         }
         else
         {
             // The player held the space key down without having a star selected.
             if (line != null)
             {
                 throw new Exception("there should be no line allocated, but there is");
             }
         }
         pressed_star = -1;
         GameDad.setmode(StarInstantiatorMode.GreenSelect);
     }
     if (line != null)
     {
         DeRez(line);
     }
 }
Пример #4
0
    public void make_starseed(int start, Vector3 startLocation, int end, Vector3 endLocation, float speed, bool isred = false)
    {
        GameObject starseed = isred? RezFind("spamseed_icon"): RezFind("starseed_icon");

        if (GameDad.get_particle_system_scale != null)
        {
            float scale = GameDad.get_particle_system_scale();
            starseed.transform.localScale *= scale;
            speed *= Mathf.Sqrt(scale);
        }
        Action whenhit = delegate() {
            if (!isred)
            {
                // a green starseed has hit a star

                // check if the hooks we need even exist
                if (GameDad.is_green == null || GameDad.get_green == null)
                {
                    return;
                }

                // if the destination star is bare, then:
                // 1. call give_chance_to_make_red_star
                // 2. if this is false, then make it green
                if (!GameDad.is_green(end))
                {
                    bool stop = false;
                    if (GameDad.give_chance_to_make_red_star != null)
                    {
                        stop = GameDad.give_chance_to_make_red_star(start, startLocation, end, endLocation);
                    }
                    if (GameDad.is_green(end))
                    {
                        stop = true;
                    }

                    if (!stop)
                    {
                        GameDad.add_green(end, null);
                        if (GameDad.update_best != null)
                        {
                            GameDad.update_best();
                        }
                    }
                }
                else if (GameDad.get_green(end).type == greenstar.Type.Red)  // test
                // a green starseed has hit a red star.
                // send a red starseed back
                {
                    if (GameDad.send_red_hook != null)
                    {
                        GameDad.send_red_hook(end, start);
                    }
                }

                /*
                 * var star = new greenstar();
                 * star.isred = true;
                 * GameDad.add_green(end, star);
                 */
            }
            else
            {
                // a red starseed has hit a star

                if (GameDad.spamseed_lands_on_star != null)
                {
                    GameDad.spamseed_lands_on_star(end, endLocation - startLocation); // test
                    if (GameDad.update_best != null)
                    {
                        GameDad.update_best();
                    }
                }
            }
        };

        starseeds[id++] = new starseed_owner(startLocation, endLocation, speed, starseed, whenhit, isred);
    }