Exemplo n.º 1
0
    public void update_best()
    {
        if (died)
        {
            return;
        }
        if (GameDad.gamesover)
        {
            return;
        }

        cur = GameDad.farthest_green_star();
        if (time == -1f)
        {
            start_timer_if_there_are_green_starseeds();
        }
        if (cur == -1)
        {
            if (GameDad.are_there_green_starseeds != null && !GameDad.are_there_green_starseeds())
            {
                gameover("HUMANS EXTINCT");
            }
            else
            {
                cur = 0f;
            }
        }
        if (cur > max)
        {
            max = cur;
        }
        max_is_on = cur < max;
    }
Exemplo n.º 2
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]);
    }
Exemplo n.º 3
0
 void space_pressed()
 {
     if (pressed == false)
     {
         pressed = true;
         if (line != null)
         {
             throw new Exception("line already created even though pressed is false");
         }
         if (pressed_star != -1)
         {
             throw new Exception("pressed_star != -1 even though pressed is false");
         }
         if (GameDad.selectedStar != -1)
         {
             pressed_star          = GameDad.selectedStar;
             pressed_star_position = GameDad.selectedStarLocation;
             line = Rez(Find("line_template"));
             line.SetActive(true);
             line_currently_red = false;
             GameDad.setmode(StarInstantiatorMode.AnyStarSelect);
         }
         // If there is no selected star, we still set pressed to true,
         // but we leave pressed_star at -1.
     }
 }
Exemplo n.º 4
0
 void start_timer_if_there_are_green_starseeds()
 {
     if (GameDad.are_there_green_starseeds != null && GameDad.are_there_green_starseeds())
     {
         time = 0;
     }
 }
Exemplo n.º 5
0
    public void launch()
    {
        bool stop = false;

        while (0 <= current_candidate && current_candidate < candidates.Length && !stop)
        {
//            if(GameDad.star_corresponds_to_particle(candidates[current_candidate])) {
//                GameDad.send_red_hook(ix, candidates[current_candidate]);
//                stop = true;
//            }
            GameDad.send_red_hook(ix, candidates[current_candidate]);
            stop = true;
            current_candidate++;
        }
        if (!stop)
        {
            if (candidates.Length > 0)
            {
                int r = UnityEngine.Random.Range(0, candidates.Length);
                GameDad.send_red_hook(ix, candidates[r]);
//                if(GameDad.star_corresponds_to_particle(candidates[r])) {
//                    GameDad.send_red_hook(ix, candidates[r]);
//                }
            }
        }
    }
Exemplo n.º 6
0
    public override void update()
    {
        if (GameDad.setmode == null || GameDad.linedrawn_hook == null)
        {
            // the hooks are not set up, we should wait for the other scripts
            // setmode should come from starinstantiator
            // and linedrawn_hook should come from launch
            return;
        }
        bool space = Input.GetKey("space");

        if (GameDad.headset_button_is_pushed != null && GameDad.headset_button_is_pushed())
        {
            space = true;
        }
        if (GameDad.gamesover) // no button once the game is over
        {
            space = false;
        }
        if (space)
        {
            if (pressed == false)
            {
                space_pressed();
            }
            updateline();
        }
        else
        {
            if (pressed == true)
            {
                space_release();
            }
        }
    }
Exemplo n.º 7
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);
     }
 }
Exemplo n.º 8
0
 public void gamedad_make_red(int ix, Vector3 vector, bool has_a_launcher)
 {
     red_stars[ix] = make_new_red_star(ix, vector);
     if (has_a_launcher)
     {
         red_stars[ix].has_a_launcher = true;
     }
     GameDad.add_green(ix, red_stars[ix].star);
 }
Exemplo n.º 9
0
    public void send_red(int start, int end)
    {
        if (GameDad.gamesover)
        {
            return; // no starseeds launch after game over
        }
        Vector3 startLocation = GameDad.whereisstar(start);
        Vector3 endLocation   = GameDad.whereisstar(end);

        make_starseed(start, startLocation, end, endLocation, 0.01f, true);
    }
Exemplo n.º 10
0
 void mouseover_nothing()
 {
     if (mouseoverindex != -1)
     {
         mouseoverindex = -1;
     }
     GameDad.selectedStar         = -1;
     GameDad.selectedStarLocation = new Vector3(0, 0, 0);
     if (GameDad.starmouseover_hook != null)
     {
         GameDad.starmouseover_hook(-1, new Vector3(0, 0, 0));
     }
 }
Exemplo n.º 11
0
    void update_particle_system_tf()
    {
        if (instantiated == null)
        {
            return;
        }
        if (GameDad.get_particle_system_scale == null || GameDad.get_particle_system_position == null)
        {
            return;
        }
        float   scale    = GameDad.get_particle_system_scale();
        Vector3 position = GameDad.get_particle_system_position();

        instantiated.transform.localScale    = new Vector3(scale, scale, scale);
        instantiated.transform.localPosition = position;
    }
Exemplo n.º 12
0
 public void update()
 {
     if (has_a_launcher)
     {
         launch_clock += Time.deltaTime;
         if (launch_clock > 2f)
         {
             launch_clock -= 2f;
             launch();
         }
     }
     if (redstar.exponential_decay(1 / Config.red_average_life))
     {
         GameDad.red_star_evaporate(ix);
         return;
     }
 }
Exemplo n.º 13
0
 public override void update()
 {
     if (GameDad.update_particle_system_tf == null)
     {
         return;
     }
     if (Input.GetKeyDown("-"))
     {
         scaleby(1 / 1.1f);
     }
     if (Input.GetKeyDown("="))
     {
         scaleby(1.1f);
     }
     if (Input.GetKey("left"))
     {
         moveby(Vector3.left);
     }
     if (Input.GetKey("right"))
     {
         moveby(Vector3.right);
     }
     if (Input.GetKey("up"))
     {
         moveby(Vector3.forward);
     }
     if (Input.GetKey("down"))
     {
         moveby(Vector3.back);
     }
     if (Input.GetKey("page up"))
     {
         moveby(Vector3.up);
     }
     if (Input.GetKey("page down"))
     {
         moveby(Vector3.down);
     }
     if (dirty)
     {
         Debug.Log(String.Format("updating {0}", scale));
         GameDad.update_particle_system_tf();
         dirty = false;
     }
 }
Exemplo n.º 14
0
 public override void update()
 {
     if (GameDad.selectedStar != -1)
     {
         time += 40 * Time.deltaTime;
         setactive(true); // test
         cyl.transform.position = GameDad.selectedStarLocation;
         float s = 0.004f * (1 + Mathf.Exp(-time / 20f));
         if (GameDad.get_particle_system_scale != null)
         {
             s *= GameDad.get_particle_system_scale();
         }
         cyl.transform.localScale = new Vector3(s, s, s * 0.1f);
         //cyl.transform.rotation = Quaternion.Euler(0, time, 0);
     }
     else
     {
         setactive(false);
     }
 }
Exemplo n.º 15
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);
     }
 }
Exemplo n.º 16
0
 public void flip()
 {
     //if(ix == GameDad.sol_index)
     //    return; // this is handled by earthblinks
     if (!GameDad.is_green(ix))
     {
         throw new Exception("red star was not green??");
     }
     if (star.size == 0.02f)
     {
         star.size  = 0.011f;
         star.color = greenstar.StarColor.RedSmall;
     }
     else
     {
         star.size  = 0.02f;
         star.color = greenstar.StarColor.RedLarge;
     }
     //star.size = 0.031f - star.size;
     GameDad.update_green(ix);
 }
Exemplo n.º 17
0
    void mouseover_star(int index)
    {
        if (index < 0 || index >= particles.Length)
        {
            throw new System.Exception("hey index was invalid");
        }
        int starix = particle_to_first_star[index];

        if (index != star_to_particle_range[starix].start)
        {
            throw new System.Exception("hey star was not the first star in group");
        }
        mouseoverindex = index;
        Vector3 loca = particlepos(mouseoverindex);

        GameDad.selectedStar         = starix;
        GameDad.selectedStarLocation = loca;
        if (GameDad.starmouseover_hook != null)
        {
            GameDad.starmouseover_hook(starix,
                                       loca);
        }
    }
Exemplo n.º 18
0
 public void red_star_evaporate(int ix)
 {
     red_stars.Remove(ix);
     GameDad.remove_green(ix);
     quiet_stars[ix] = Config.quiettime;
 }
Exemplo n.º 19
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);
    }
Exemplo n.º 20
0
 bool too_far(Vector3 diff)
 {
     return(GameDad.realvector_to_spacevector(diff).magnitude > 4);
 }