Esempio n. 1
0
    private void MakeObjects()
    {
        // CENTER OF THE SPHERE: x = 0, y = 20, z = 0 I generate an object there
        GameObject _pivot = new GameObject();

        _pivot.transform.position = new Vector3(0, sphereRadius, 0);

        for (int i = 0; i < max_objects; i++)
        {
            // WE make a small sphere
            GameObject _sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            // WE SCALE THE SPHERE
            _sphere.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
            // TAKE A SCALED RANDOM POSITION
            Vector3 pos = ScalePosition(urand.PointOnASphere());
            // WE set the sphere position
            _sphere.transform.position = pos;
            // WE give a tag to the sphere
            _sphere.tag = "Player";
            // Attach the rotation script
            RotateAround _ra = _sphere.AddComponent <RotateAround>();
            // SET the PIVOT POINT IN SCRIPT
            _ra.pivotPoint = _pivot.transform;
            // SET the MATERIAL as a RANDOM COLOR
            _sphere.renderer.material.color = urand.Rainbow();
        }
    }
Esempio n. 2
0
    void UpdateAmmoCount()
    {
        EmptyObject.transform.rotation = Quaternion.identity;

        for (int i = 0; i < ammoShow.Count; i++)
        {
            Destroy(ammoShow[i]);
        }

        ammoShow.Clear();

        for (int i = ammoShow.Count; i < ammo; i++)
        {
            GameObject g = Instantiate(Souls, transform.position, Quaternion.identity) as GameObject;
            ammoShow.Add(g);
        }

        for (int i = 0; i < ammoShow.Count; i++)
        {
            float angle = 360 / ammo;

            ammoShow[i].transform.position = transform.position + EmptyObject.transform.up + new Vector3(0, 0, -5);
            ammoShow[i].transform.SetParent(transform);
            EmptyObject.transform.Rotate(0, 0, angle);
            RotateAround other = (RotateAround)ammoShow[i].GetComponent(typeof(RotateAround));
            other.init(transform);
            ammoShow[i].transform.rotation = EmptyObject.transform.rotation;
            ammoShow[i].transform.Rotate(0, 0, 5 * ammo);
        }
    }
Esempio n. 3
0
        private void ShowWeaponModel(int equipId)
        {
            DestroyModel();

            EquipModel.CreateModel(equipId, go =>
            {
                if (null == go)
                {
                    return;
                }
                go.transform.parent = EquipModel.transform;
                go.gameObject.SetLayerRecursive(LayerMask.NameToLayer(GAMELAYER.UI));
                go.gameObject.SetRenderQueue(ModelRenderQueue);
                if (rotateAround == null)
                {
                    rotateAround = go.GetComponentInChildren <RotateAround>();
                    if (rotateAround != null)
                    {
                        initRotate = rotateAround.gameObject.transform.localRotation;
                    }
                }
                else
                {
                    rotateAround.transform.localRotation = initRotate;
                }
            }, true);
        }
Esempio n. 4
0
 private void Start()
 {
     rotA = GetComponent <RotateAround>();
     if (rotA == null)
     {
         rotA = GetComponentInParent <RotateAround>();
     }
     _transform = transform;
 }
Esempio n. 5
0
    void Start()
    {
        this.camera = GameObject.Find("Main Camera");

        GameObject sun = GameObject.Find("Sun");

        GameObject[] planets = GameObject.FindGameObjectsWithTag("Planet");
        camera.transform.LookAt(sun.transform);

        for (int i = 0; i < planets.Length; i++)
        {
            RotateAround rotateObj = planets[i].AddComponent <RotateAround>();
            rotateObj.target = sun;
            rotateObj.speed  = translationSpeed[planets[i].name] * scale;

            PlanetController controller = planets[i].AddComponent <PlanetController>();
            controller.OnPlanetClick += FocusCamera;
            controller.speed          = rotationSpeed[planets[i].name] * scale;
        }

        GameObject       moon           = GameObject.Find("Moon");
        PlanetController moonController = moon.AddComponent <PlanetController>();

        moonController.OnPlanetClick += FocusCamera;
        moonController.speed          = 2 * scale;

        PlanetController sunController = sun.AddComponent <PlanetController>();

        sunController.OnPlanetClick += FocusCamera;
        sunController.speed          = rotationSpeed["Sun"] * scale;

        GameObject[] moons = GameObject.FindGameObjectsWithTag("Moon");
        for (int i = 0; i < moons.Length; i++)
        {
            RotateAround rotateObj = moons[i].AddComponent <RotateAround>();
            rotateObj.target = moons[i].transform.parent.gameObject;
            rotateObj.speed  = Random.Range(1, 5f);

            PlanetController controller = moons[i].AddComponent <PlanetController>();
            controller.speed = Random.Range(1, 2f);
        }

        for (int n = 0; n < 200; n++)
        {
            GameObject g = Instantiate(meteor);

            float z = Random.Range(-40, 40f);
            float x = ResolveCircle(z);

            g.transform.position = new Vector3(x, 0, z);

            RotateAround rotateObj = g.AddComponent <RotateAround>();
            rotateObj.target = sun;
            rotateObj.speed  = Random.Range(0.5f, 3f);
        }
    }
Esempio n. 6
0
    void Awake()
    {
        GetComponent <NavMeshAgent>().enabled = false;

        m_LastScriptRotationState = transform.localRotation;
        m_LastModelRotationState  = transform.GetChild(0).localRotation;
        m_SpotLight = GetComponentInChildren <Light>();
        m_SpotLightScanningColor = m_SpotLight.color;
        m_Rotater = GetComponentInParent <RotateAround>();
    }
Esempio n. 7
0
    // Use this for initialization
    protected override void Start()
    {
        base.Start();
        mMeshRenderer.material.color = Color.red;
        name = "Red Knight";
        RotateAround tScript = gameObject.AddComponent <RotateAround> ();

        tScript.Axis  = Vector3.right;
        tScript.Speed = 100f;
    }
Esempio n. 8
0
    /// <summary>
    /// Init class method.
    /// </summary>
    private void Init()
    {
        // get rigibody component reference.
        _rigi = GetComponent <Rigidbody>();

        // get rotate itself class component reference.
        _rotateItself = GetComponent <RotateItself>();

        // get rotate around class component reference.
        _rotateAround = GetComponent <RotateAround>();
    }
Esempio n. 9
0
    // Use this for initialization
    void Start()
    {
        scale = ScaleController.scale;
        rot   = GetComponent <RotateAround>();
        trans = GetComponent <Transform>();
        trail = GetComponentInChildren <TrailRenderer>();

        trans.localScale      *= scale;
        rot.planetSunDistance *= scale;
        rot.Kepler            /= scale;
        trail.startWidth      *= scale;

        rot.reStart();
    }
Esempio n. 10
0
 void OnCollisionEnter(Collision coll)
 {
     if (hit == false)
     {
         //if the tag on the hit collider gameobject is "Target", then disable the followball camera and enable the rotate camera
         if (coll.gameObject.CompareTag("Target"))
         {
             hit                      = true;                                          //so the ball can't trigger two things at once
             rotateScript             = coll.gameObject.GetComponent <RotateAround>(); //getting the RotateAround component on the hit object
             rotateScript.startRotate = true;                                          //start rotating the gameobject camera is attached to
             if (coll.gameObject.name == "Statue1")                                    //passing an integer to CameraManager RotateCamera function to differentiate between cameras
             {
                 cameraManager.RotateCamera(1);
             }
             else if (coll.gameObject.name == "Statue2")
             {
                 cameraManager.RotateCamera(2);
             }
             else if (coll.gameObject.name == "Statue3")
             {
                 cameraManager.RotateCamera(3);
             }
             else if (coll.gameObject.name == "Statue4")
             {
                 cameraManager.RotateCamera(4);
             }
         }
         //if the tag on the hit collider gameobject is "Missed", then disable followball camera and enable the default camera
         else if (coll.gameObject.CompareTag("Missed"))
         {
             Debug.Log("I missed the target");
             hit = true;
             cameraManager.DefaultCamera();
         }
         else if (coll.gameObject.CompareTag("Ground"))
         {
             Debug.Log("I hit the ground");
             hit = true;
             cameraManager.DefaultCamera();
         }
     }
 }
Esempio n. 11
0
    public override void MouseDown(MouseInputManager.MouseButton btn, MouseInputManager.MousePointer mouse, Interactable echo = null)
    {
        if (!btn.Equals(MouseInputManager.MouseButton.LEFT_BUTTON))
        {
            return;
        }
        if (echo)
        {
            return;
        }

        Debug.Log("down");
        if (!holdBy)
        {
            holdBy        = this;
            currentSpeed += speed;
            (Echo as RotateAround).currentSpeed            += speed;
            Echo.GetComponent <Button>().interactable       = false;
            (Echo as RotateAround).OtherButton.interactable = false;
        }
    }
Esempio n. 12
0
    public override void MouseUp(MouseInputManager.MouseButton btn, MouseInputManager.MousePointer mouse, Interactable echo = null)
    {
        if (!btn.Equals(MouseInputManager.MouseButton.LEFT_BUTTON))
        {
            return;
        }
        if (echo)
        {
            return;
        }
        Debug.Log("up");
        Debug.Log("=======");

        if (holdBy == this)
        {
            holdBy       = null;
            currentSpeed = 0;
            (Echo as RotateAround).currentSpeed             = 0;
            Echo.GetComponent <Button>().interactable       = true;
            (Echo as RotateAround).OtherButton.interactable = true;
        }
    }
Esempio n. 13
0
 void Update()
 {
     if (aiState == 0)
     {
         if (gamecontrol.GetDistanceTo(transform.position, gamecontrol.GetPlayerLoc()) < targetRadius)
         {
             Move movement = new Move(this, gamecontrol.GetPlayerLoc());
             movement.Execute();
         }
         else
         {
             aiState += 1;
         }
     }
     else
     {
         RotateAround rot = new RotateAround(this, 200, gamecontrol.GetPlayerLoc(), targetRadius);
         rot.Execute();
         RotateTo rot2 = new RotateTo(this, gamecontrol.GetPlayerLoc(), 999);
         rot2.Execute();
     }
 }
Esempio n. 14
0
        private void CreateModel()
        {
            if (itemListLogic == null)
            {
                return;
            }

            if (model != null)
            {
                return;
            }

            var t = itemListLogic.Item as EquipModelDataModel;

            if (t != null)
            {
                DestroyModel();
                EquipModel.CreateModel(t.EquipId, go =>
                {
                    if (null == go)
                    {
                        return;
                    }
                    model = go;
                    go.transform.parent = EquipModel.transform;
                    go.gameObject.SetLayerRecursive(LayerMask.NameToLayer(GAMELAYER.PerspectiveView));
                    go.gameObject.SetRenderQueue(ModelRenderQueue);

                    rotateAround = go.GetComponentInChildren <RotateAround>();
                    if (rotateAround != null)
                    {
                        initRotate = rotateAround.gameObject.transform.localRotation;
                    }
                    SetRotate();
                }, true);
            }
        }
 public void RegisterRotateAround(RotateAround rotateAroundToRegister)
 {
     this.objectsToCheck.Add(rotateAroundToRegister.gameObject);
 }
Esempio n. 16
0
    public void SetUpSpeed(RotateAround rot)
    {
        targetValue = -rot.CurrentSpeed / 25.0f;

        goBackToZero = true;
    }
Esempio n. 17
0
 private void Start()
 {
     instance = this;
 }
Esempio n. 18
0
 private void Awake()
 {
     Instance = this;
 }
Esempio n. 19
0
 void Start()
 {
     _covidManager = FindObjectOfType <Covid>();
     _rotate       = GetComponent <RotateAround>();
 }
Esempio n. 20
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        RotateAround rotateAround = (RotateAround)target;

        GUILayout.Label("Determines direction of the rotation");

        GUILayout.BeginHorizontal();

        if (GUILayout.Button("Counter Clockwise"))
        {
            rotateAround.GoCounterClockwise();
        }

        if (GUILayout.Button("Clockwise"))
        {
            rotateAround.GoClockwise();
        }

        GUILayout.EndHorizontal();

        GUILayout.Space(10);

        GUILayout.Label("Determines the speed at which the object rotates the object");
        rotateAround.rotateSpeed = EditorGUILayout.Slider("Rotation Speed", rotateAround.rotateSpeed, 0f, 500f);

        GUILayout.Space(10);

        GUILayout.Label("Determines the color of the object. Make sure to click Change!");
        GUILayout.BeginHorizontal();
        matColor = EditorGUILayout.ColorField("New Color", matColor);
        if (GUILayout.Button("Change"))
        {
            rotateAround.SetColor(matColor);
        }

        GUILayout.EndHorizontal();

        if (rotateAround.target == null)
        {
            EditorGUILayout.HelpBox("Missing a target to rotate around", MessageType.Warning);
        }

        showPosition = EditorGUILayout.Foldout(showPosition, status);
        if (showPosition)
        {
            GUILayout.Label("This option invites chaos. It works...sometimes?");
        }
        if (Selection.activeTransform)
        {
            rotateAround.RotateVector =
                EditorGUILayout.Vector3Field("Axis", rotateAround.RotateVector);
            status = "Advanced";
        }
        if (!Selection.activeTransform)
        {
            status       = "Select a GameObject";
            showPosition = false;
        }
    }