Пример #1
0
 void Update()
 {
     if (Input.GetMouseButtonDown(0) && EventSystem.current.IsPointerOverGameObject() == false)
     {
         RaycastHit2D[] t_hitArray = Physics2D.RaycastAll(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
         if (t_hitArray != null && t_hitArray.Length > 0)
         {
             CS_Planet t_planetMin1st = null;
             CS_Planet t_planetMin2nd = null;
             foreach (RaycastHit2D t_hit in t_hitArray)
             {
                 CS_Planet f_planet = t_hit.collider.GetComponent <CS_Planet> ();
                 f_planet = FillMinSizePlanet(ref t_planetMin1st, f_planet);
                 FillMinSizePlanet(ref t_planetMin2nd, f_planet);
             }
             if (t_planetMin1st != null)
             {
                 if (t_planetMin1st.OnClick() == false)
                 {
                     if (t_planetMin2nd != null)
                     {
                         t_planetMin2nd.OnClick();
                     }
                 }
             }
         }
     }
 }
Пример #2
0
    public void Init(CS_Planet g_parent, float g_radius, float g_speed, float g_rotationZ, string g_sfx, Gradient g_gradient = null)
    {
        myParent = g_parent;
        if (myParent != null)
        {
            myParent.SetChild(this);
        }

        myMultiplier_Radius = g_radius;
        myMultiplier_Speed  = g_speed;
        myStartRotationZ    = g_rotationZ;
        myRotationZ         = g_rotationZ;

        // set color
        if (g_gradient == null)
        {
            HideLine();
        }
        else
        {
            myLineRenderer.colorGradient = g_gradient;
        }

        mySFX = g_sfx;
    }
Пример #3
0
    public bool OnClickPlanet(CS_Planet g_planet)
    {
        AiryAudioSource t_airyAudioSource = AiryAudioManager.Instance.InitAudioSource("Button");

        AiryAudioActions.Play(t_airyAudioSource);

        CS_CameraManager.Instance.LookAt(g_planet);
        foreach (Level t_level in myLevels)
        {
            if (t_level.planet == g_planet)
            {
                CS_DataManager.Instance.myArrangeList = t_level.arrangeList;
                SceneManager.LoadSceneAsync(t_level.sceneName);

                t_airyAudioSource = AiryAudioManager.Instance.InitAudioSource("Drop");
                AiryAudioActions.Play(t_airyAudioSource);
                return(true);
            }
        }
        return(true);
    }
Пример #4
0
    public bool OnClickPlanet(CS_Planet g_planet)
    {
        if (myCurrentPlanet == g_planet)
        {
            return(false);
        }

        AiryAudioSource t_airyAudioSource = AiryAudioManager.Instance.InitAudioSource("Drop");

        AiryAudioActions.Play(t_airyAudioSource);


        myCurrentPlanet = g_planet;
        CS_CameraManager.Instance.LookAt(g_planet);

        if (myPlanetRootList.Contains(g_planet) || g_planet == null)
        {
            myPage_Planet.SetActive(false);
            myArea_Speed.Set(null);
            myArea_Radius.Set(null);
        }
        else
        {
            myPage_Planet.SetActive(true);
            myArea_Radius.Set(g_planet);
            if (myPlanetEndList.Contains(g_planet))
            {
                myArea_Speed.gameObject.SetActive(false);
                myArea_Speed.Set(null);
            }
            else
            {
                myArea_Speed.gameObject.SetActive(true);
                myArea_Speed.Set(g_planet);
            }
        }

        return(true);
    }
Пример #5
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="g_spot">a spot to store smaller planet</param>
    /// <param name="g_target">planet to compare with</param>
    /// <returns>the larger planet</returns>
    private CS_Planet FillMinSizePlanet(ref CS_Planet g_spot, CS_Planet g_target)
    {
        if (g_target == null)
        {
            return(null);
        }

        CS_Planet t_origin = g_spot;

        if (t_origin == null)
        {
            g_spot = g_target;
            return(null);
        }

        if (t_origin.GetRadius() > g_target.GetRadius())
        {
            g_spot = g_target;
            return(t_origin);
        }

        return(g_target);
    }
Пример #6
0
 public void SetChild(CS_Planet g_child)
 {
     myChildrenList.Add(g_child);
     g_child.transform.SetParent(myTransform_Children);
     isEnd = false;
 }
Пример #7
0
    private void Start()
    {
        // init UI
        // hide planet page
        myPage_Planet.SetActive(false);
        // init slider
        mySlider_Main.SetValueWithoutNotify(Mathf.Sqrt(myRootSpeed / myRootSpeedMultiplier));
        // hide current option
        myCurrentOption.gameObject.SetActive(false);
        // hide show all button
        myObject_ButtonShow.SetActive(false);
        myObject_ButtonGameOverHome.SetActive(false);
        // hide menu
        myPage_Menu.SetActive(false);
        // hide game over effect
        myObject_GameOver.SetActive(false);

        // get arrange list
        myArrangeList = CS_DataManager.Instance.myArrangeList;

        // get seed
        seed = (int)System.DateTime.Now.Ticks;
        Random.InitState(seed);

        // temp store parent
        List <CS_Planet> t_answerParents = new List <CS_Planet> ();

        // create answer list
        for (int i = 0; i < myArrangeList.Count; i++)
        {
            // create planet
            GameObject f_planetObject = Instantiate(myPlanetPrefab, this.transform);
            CS_Planet  f_planet       = f_planetObject.GetComponent <CS_Planet> ();
            float      f_radius       = myRootRadius;
            float      f_speed        = myAnswerSpeed;
            // get parent
            CS_Planet f_parent = null;
            if (myArrangeList[i] >= i)
            {
                // root
                f_parent = null;
                t_answerParents.Add(f_planet);
            }
            else
            {
                f_parent = myAnswerList[myArrangeList[i]];
                // get random radius and speed for list
                f_radius = myRadiusList[Random.Range(0, myRadiusList.Count)];
                f_speed  = mySpeedList[Random.Range(0, mySpeedList.Count)];
                // random speed sign
                if (f_speed != 1)
                {
                    f_speed = (Random.Range(0, 2) * 2 - 1) * f_speed;
                }

                Debug.Log(f_radius + "-" + f_speed);
            }
            // get random rotation Z
            float f_rotationZ = Random.Range(0, 360f);
            //if (f_parent != null) {
            //    CS_Planet t_brother = f_parent.GetChild ();
            //    if (t_brother != null) {
            //        f_rotationZ = t_brother.GetStartRotationZ () + 180;
            //    }
            //}
            if (f_parent == null)
            {
                if (t_answerParents.Count > 0)
                {
                    f_rotationZ = t_answerParents[0].GetStartRotationZ() + 180;
                }
            }
            // init planet
            f_planet.Init(f_parent, f_radius, f_speed, f_rotationZ, "L" + GetSoundIndex(f_radius).ToString());
            // add to list
            myAnswerList.Add(f_planet);
        }

        // set parent speed
        foreach (CS_Planet f_planet in t_answerParents)
        {
            f_planet.SetMultiplier_Speed(myAnswerSpeed / f_planet.GetChildMaxSpeedMultiplier());
        }


        // create planets
        for (int i = 0; i < myArrangeList.Count; i++)
        {
            // create planet
            GameObject f_planetObject = Instantiate(myPlanetPrefab, this.transform);
            f_planetObject.name = "Planet (" + i + ")";
            CS_Planet f_planet = f_planetObject.GetComponent <CS_Planet> ();
            float     f_radius = myRootRadius;
            float     f_speed  = myRootSpeed;
            // get parent
            CS_Planet f_parent = null;
            if (myArrangeList[i] >= i)
            {
                // root
                f_parent = null;
                myPlanetRootList.Add(f_planet);
            }
            else
            {
                f_parent = myPlanetList[myArrangeList[i]];
                f_radius = myDefaultRadius;
                f_speed  = myDefaultSpeed;
            }
            // get gradient
            Gradient f_gradient = myGradientList[Random.Range(0, myGradientList.Count)];
            // init planet
            f_planet.Init(f_parent, f_radius, f_speed, myAnswerList[i].GetStartRotationZ(), "H" + GetSoundIndex(f_radius).ToString(), f_gradient);
            // add to list
            myPlanetList.Add(f_planet);
        }

        FixedUpdate();

        // add answer trail
        foreach (CS_Planet f_planet in myAnswerList)
        {
            if (f_planet.CheckEnd() == true)
            {
                // add trail
                GameObject    f_trailObject = Instantiate(myTrailAnswerPrefab, this.transform);
                TrailRenderer f_trail       = f_trailObject.GetComponent <TrailRenderer> ();
                f_planet.SetTrail(f_trail);
            }
        }

        // add trail
        foreach (CS_Planet f_planet in myPlanetList)
        {
            if (f_planet.CheckEnd() == true)
            {
                // add trail
                GameObject    f_trailObject = Instantiate(myTrailPrefab, this.transform);
                TrailRenderer f_trail       = f_trailObject.GetComponent <TrailRenderer> ();
                f_planet.SetTrail(f_trail);
                // add to list
                myPlanetEndList.Add(f_planet);
            }
        }

        // generate options
        for (int i = 0; i < myPlanetList.Count; i++)
        {
            if (myPlanetRootList.Contains(myPlanetList[i]))
            {
                continue;
            }

            if (myPlanetEndList.Contains(myPlanetList[i]) == false)
            {
                CreateOption(myAnswerList[i].GetMultiplier_Speed());
            }
            CreateOption(myAnswerList[i].GetMultiplier_Radius());
        }
    }
Пример #8
0
 public void Set(CS_Planet g_planet)
 {
     myPlanet = g_planet;
 }
Пример #9
0
 public void LookAt(CS_Planet g_planet)
 {
     doLookAt        = true;
     myLookAtProcess = 0;
     myLookAtTarget  = g_planet;
 }