コード例 #1
0
    public bool SeekAndSelect(StarBehaviour searched)
    {
        if (m.lab)
        {
            this.canSelect = true;
            this.interact  = false;
            if (!first)
            {
                previous.canSelect = false;
                previous.interact  = false;
            }
        }

        for (int i = 0; i < neibours.Count; i++)
        {
            if (neibours[i].neibour == searched && !neibours[i].completed)
            {
                neibours[i].completed = true;

                completedStars++;

                if (completedStars == neibours.Count)
                {
                    m.connections++;
                    canSelect = false;
                }
                return(true);
            }
        }
        return(false);
    }
コード例 #2
0
    public void followTargetOnProjectionChange()
    {
        StarBehaviour sb = target.GetComponent <StarBehaviour>();

        if (sb != null)
        {
            Vector3 temp = sb.star.pos;
            if (projection == Projection.RA_DIST)
            {
                temp    = sb.star.ra_dist;
                temp.y += 2f;
            }
            else if (projection == Projection.FLAT_3D)
            {
                temp.y = 2f;
            }
            else
            {
                temp.y  = 0;
                temp.x += 2f;
                Debug.Log(sb.star.pos);
                Debug.Log(temp);
            }
            transform.position = temp;
            transform.forward  = new Vector3(0f, -1f, 0f);
        }
        else
        {
            Debug.Log("Star Behaviour not Found: followTargetOnProjectionChange");
        }
    }
コード例 #3
0
    public void LoadInformation()
    {
        if (camBeh.target != null)
        {
            sb = camBeh.target.GetComponent <StarBehaviour>();
        }
        else
        {
            Debug.Log("Null target!");
        }
        if (sb != null)
        {
            star = sb.star;
        }
        else
        {
            Debug.Log("Star behaviour was null!");
        }
        if (star != null)
        {
            textName.text         = star.name;
            textDistance.text     = "Distance: " + star.dist + "pc";
            textSpectralType.text = "Spectral Type: " + star.spectralType;
            textLuminosity.text   = "Luminosity: " + star.luminosity + "suns";
            textConstelation.text = "Constelation: " + star.constelation;


            if (star.planetTextLoaded)
            {
                textPlanetInfo.text  = star.planetText;
                textPlanetCount.text = "Known Planets: " + star.planetCount;
                textPlanetInfo.rectTransform.sizeDelta = new Vector2(textPlanetInfo.rectTransform.rect.width, star.planetCount * 210);
            }
            else
            {
                if (star.has_planets)
                {
                    if (star.hipp != null && star.hipp.Length > 0)
                    {
                        StartCoroutine(loadPlanets());
                    }
                    else
                    {
                        textPlanetCount.text = "Known Planets: 0";
                        textPlanetInfo.text  = "";
                    }
                }
                else
                {
                    textPlanetCount.text = "Known Planets: 0";
                    textPlanetInfo.text  = "";
                }
            }
        }
        else
        {
            Debug.Log("StarBehaviour.star was null!");
        }
    }
コード例 #4
0
    void shoot()
    {
        Quaternion rot = this.transform.rotation * Quaternion.Euler(0, 0, -90);
        //Debug.Log("Shoot");
        //ShootableObjects.instance.shootObject(0,this.transform.position,this.transform.rotation);
        GameObject    star = ShootableObjects.instance.shootObject(0, this.transform.position, rot);
        StarBehaviour sb   = star.GetComponent <StarBehaviour>();

        sb.ttl   = starTTL;
        sb.speed = starSpeed;
    }
コード例 #5
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.CompareTag("Score"))
        {
            StarBehaviour s = col.gameObject.GetComponent <StarBehaviour>();
            if (s == null)
            {
                Debug.LogError("Every Score-Tagged Object needs a Starbehaviour script attached");
                return;
            }

            s.Disappear();
        }
    }
コード例 #6
0
 public void SelectStar(StarBehaviour star)
 {
     hasSelected  = true;
     selectedStar = star;
     if (whiteLine)
     {
         DrawLine(selectedStar.transform.position, pos, Color.white);
     }
     else
     {
         DrawLine(selectedStar.transform.position, pos, Color.yellow);
     }
     isInstatiatedLine = false;
 }
コード例 #7
0
ファイル: HealthScript.cs プロジェクト: LOVEATWORK/teamikidas
    void OnTriggerEnter2D(Collider2D collider)
    {
        if (collider.gameObject.tag == "Player")
        {
            return;
        }
        // Is this a shot?
        StarBehaviour star = collider.gameObject.GetComponent <StarBehaviour> ();

        if (star != null)
        {
            // Avoid friendly fire
            GameState.Instance.HP -= star.damage;

            if (GameState.Instance.HP <= 0)
            {
                Kill();
            }
        }
    }
コード例 #8
0
    IEnumerator zoomToTarget()
    {
        StarBehaviour sb = target.GetComponent <StarBehaviour>();
        Star          s  = sb.star;

        float   zoomStartTime = Time.time;
        Vector3 startPos      = transform.position;

        ///on the same plane as the star:
        Vector3 flatPos = new Vector3(startPos.x, s.posY, startPos.z);

        //rethink this
        if (flatPos.magnitude == 0)           //In case we are directly above the target
        {
            flatPos.x = -2.0f;
        }

        Vector3 destination = (flatPos - s.pos).normalized * 2.5f; //The difference

        destination   = s.pos + destination;                       //The difference between the target and cam
        destination.y = s.posY;                                    //relocate the same y plane

        Quaternion lookRot = Quaternion.identity;
        Vector3    up      = new Vector3(0f, 1f, 0f);

        while ((Time.time - zoomStartTime) < 2.1f)
        {
            if (projection != Projection.PERSPECTIVE)
            {
                break;
            }
            transform.position = Vector3.Lerp(startPos, destination, (Time.time - zoomStartTime) / 2f);

            lookRot = Quaternion.LookRotation((target.transform.position - transform.position), up);

            transform.rotation = Quaternion.Slerp(transform.rotation, lookRot, (Time.time - zoomStartTime) / 2f);

            yield return(null);
        }
        yield return(null);
    }
コード例 #9
0
    void OnTriggerEnter2D(Collider2D other)
    {
        StarBehaviour star = other.GetComponent <StarBehaviour>();

        if (star == null)
        {
            return;
        }
        GameState.Instance.AddExperience(star.experiencePoints * StarCollectorGameManager.Instance.currentlyChasing);
        Debug.Log("Experience points: " + GameState.Instance.experience);
        // Debug.Log ("Multiplier: " + StarCollectorGameManager.Instance.currentlyChasing);

        SpecialEffectsHelper.Instance.StarCollected(other.gameObject.transform.position);

        gameObject.audio.Play();

        Destroy(other.gameObject);
        // Decrease the number of chasing instances
        StarCollectorGameManager.Instance.currentlyChasing -= 1;
        StarCollectorGameManager.Instance.IncrementStarsCollected();
    }
コード例 #10
0
    public void SelectSecondStar(StarBehaviour star)
    {
        if (selectedStar.SeekAndSelect(star))
        {
            am.StopAllSounds();
            star.SeekAndSelect(selectedStar);
            myLine.GetComponent <LineRenderer>().SetPosition(1, star.transform.position);
            isInstatiatedLine = true;
            am.PlayScaleSound();


            if (star.canSelect)
            {
                selectedStar.Desselect();
                star.SelectStar();
            }

            else
            {
                selectedStar.Desselect();
            }
        }
        else
        {
            DeleteLine();
            if (star.canSelect)
            {
                selectedStar.Desselect();
                star.SelectStar();
            }
            else
            {
                selectedStar.Desselect();
            }
        }
    }
コード例 #11
0
    IEnumerator CheckStars()
    {
        while (!LoadStars.loadingFinished)
        {
            yield return(null);
        }
        gameObjects = new GameObject[LoadStars.starsLength];
        float sqrParsecLimit = LoadStars.parsecLimit * LoadStars.parsecLimit;

        //Refresh visible stars
        while (Application.isPlaying)
        {
            yield return(null);            //pause one frame

            int lb = 0;
            for (int i = 0; i < LoadStars.starsLength; i++)
            {
                if (LoadStars.stars[i] == null)
                {
                    Debug.Log("Fudge!");
                }
                else
                {
                    //Check VISIBLE DISTANCES
                    bool show = false;
                    if (CameraBehaviour.projection == CameraBehaviour.Projection.PERSPECTIVE)
                    {
                        if ((LoadStars.stars[i].pos - camB.target.transform.position).sqrMagnitude <= sqrParsecLimit)
                        {
                            show = true;
                        }
                    }
                    else if (CameraBehaviour.projection == CameraBehaviour.Projection.FLAT_3D)
                    {
                        Vector3 temp = LoadStars.stars[i].pos - camTransform.position;
                        temp.y = 0;
                        if (temp.sqrMagnitude <= sqrParsecLimit)
                        {
                            show = true;
                        }
                    }
                    else if (CameraBehaviour.projection == CameraBehaviour.Projection.RA_DIST)
                    {
                        if ((LoadStars.stars[i].ra_dist - camTransform.position).sqrMagnitude <= sqrParsecLimit)
                        {
                            show = true;
                        }
                    }
                    if (show == true)
                    {
                        if (gameObjects[i] == null && LoadStars.stars[i] != null)
                        {
                            gameObjects[i] = new GameObject(LoadStars.stars[i].name);

                            MeshRenderer mr = gameObjects[i].AddComponent <MeshRenderer>();
                            MeshFilter   mf = gameObjects[i].AddComponent <MeshFilter>();

                            mf.mesh = m;


                            if (LoadStars.stars[i].spectralType.Length > 0)
                            {
                                char type = LoadStars.stars[i].spectralType[0];

                                if (type == 'G')
                                {
                                    mr.material = mG;                                     // = new Color(225, 159, 100);
                                }
                                else if (type == 'A' || type == 'a')
                                {
                                    mr.material = mA;
                                }
                                else if (type == 'B' || type == 'b')
                                {
                                    mr.material = mB;
                                }
                                else if (type == 'F' || type == 'f')
                                {
                                    mr.material = mF;
                                }
                                else if (type == 'K' || type == 'k')
                                {
                                    mr.material = mK;
                                }
                                else if (type == 'M' || type == 'm')
                                {
                                    mr.material = mM;
                                }
                                else
                                {
                                    mr.material = mG;
                                }
                            }
                            else
                            {
                                mr.material = mG;
                            }

                            StarBehaviour sb = gameObjects[i].AddComponent <StarBehaviour>();

                            gameObjects[i].transform.position = LoadStars.stars[i].pos;
                            //Edited:  Moved size by luminosity to after new gameobject check


                            sb.star = LoadStars.stars[i];

                            sb.t_toCopy = textPrefab;
                        }
                        else                         //if gameobject is ALREADY DEFINED
                        {
                            if (LoadStars.stars[i].has_planets)
                            {
                                StarBehaviour sb = gameObjects[i].GetComponent <StarBehaviour>();
                                if (sb != null)
                                {
                                    if (planetaryHighlight)
                                    {
                                        if (!sb.isShowingPlanets)
                                        {
                                            gameObjects[i].GetComponent <MeshRenderer>().material = mPlanetary;
                                            sb.isShowingPlanets = true;
                                        }
                                    }
                                    else
                                    {
                                        if (sb.isShowingPlanets)
                                        {
                                            if (LoadStars.stars[i].spectralType.Length > 0)
                                            {
                                                char type = LoadStars.stars[i].spectralType[0];

                                                if (type == 'G')
                                                {
                                                    gameObjects[i].GetComponent <MeshRenderer>().material = mG;                                                    // = new Color(225, 159, 100);
                                                }
                                                else if (type == 'A' || type == 'a')
                                                {
                                                    gameObjects[i].GetComponent <MeshRenderer>().material = mA;
                                                }
                                                else if (type == 'B' || type == 'b')
                                                {
                                                    gameObjects[i].GetComponent <MeshRenderer>().material = mB;
                                                }
                                                else if (type == 'F' || type == 'f')
                                                {
                                                    gameObjects[i].GetComponent <MeshRenderer>().material = mF;
                                                }
                                                else if (type == 'K' || type == 'k')
                                                {
                                                    gameObjects[i].GetComponent <MeshRenderer>().material = mK;
                                                }
                                                else if (type == 'M' || type == 'm')
                                                {
                                                    gameObjects[i].GetComponent <MeshRenderer>().material = mM;
                                                }
                                                else
                                                {
                                                    gameObjects[i].GetComponent <MeshRenderer>().material = mG;
                                                }
                                            }
                                            else
                                            {
                                                gameObjects[i].GetComponent <MeshRenderer>().material = mG;
                                            }
                                            sb.isShowingPlanets = false;
                                        }
                                    }                                     //end of planetary highlight check

                                    //Size by luminosity?
                                }
                                else
                                {
                                    Debug.Log("Starbehaviour was null!");
                                }
                            }
                            //if has_has planets, check that its material is correct
                            //
                        }
                        if (sizeByLuminosity)
                        {
                            float scaler = 1;
                            float.TryParse(LoadStars.stars[i].luminosity, out scaler);
                            scaler = Mathf.Sqrt(scaler);
                            gameObjects[i].transform.localScale = new Vector3(scaler, scaler, scaler);
                        }
                        else
                        {
                            gameObjects[i].transform.localScale = new Vector3(1, 1, 1);
                        }
                        lb++;
                        if (lb >= 3000)
                        {
                            lb = 0; yield return(null);
                        }
                    }
                    else
                    {
                        if (gameObjects[i] != null)
                        {
                            if (camB.target != gameObjects[i])
                            {
                                Destroy(gameObjects[i]);
                            }
                        }
                    }
                }
            }
            yield return(null);
        }
        yield return(null);
    }
コード例 #12
0
 private void Start()
 {
     cam  = Camera.main.transform;
     star = GetComponent <StarBehaviour>();
     generationDistance = star.Scale * 5f;
 }