Inheritance: MonoBehaviour
Esempio n. 1
0
    private void SetComponents()
    {
        m_Walker   = GetComponent <SplineWalker>();
        m_Collider = GetComponent <Collider>();
        m_Animator = GetComponent <Animator>();

        m_offerState = WaiterOfferState.free;
    }
Esempio n. 2
0
 private void Start()
 {
     walker = GetComponent <SplineWalker>();
     gaze   = GetComponent <GazeObject>();
     ResetInteractable();
     GameFlowManager.Instance.Register(GameState.COCOON, () => ResetInteractable());
     GameFlowManager.Instance.Register(GameState.FRUIT, () => ResetInteractable());
     GameFlowManager.Instance.Register(GameState.BIRD, () => ResetInteractable());
     GameFlowManager.Instance.Register(GameState.DOG, () => ResetInteractable());
     GameFlowManager.Instance.Register(GameState.PINWHEEL, () => Destroy(gameObject));
 }
Esempio n. 3
0
 // Use this for initialization
 IEnumerator Start()
 {
     Walker = GetComponent<SplineWalker>();
     // As usual: Wait for the spline
     while (!Walker.Spline.IsInitialized)
         yield return null;
     // register for the OnGetScale event of the MeshBuilder
     SplineMesh.OnGetScale += new SplinePathMeshBuilder.OnGetScaleEvent(SplineMesh_OnGetScale);
     // store min/max TF where we have to change the scale of the mesh
     meshMinTF = SplineMesh.Spline.DistanceToTF(SplineMesh.Spline.TFToDistance(SplineMesh.FromTF) - sphereRadius);
     meshMaxTF = SplineMesh.Spline.DistanceToTF(SplineMesh.Spline.TFToDistance(SplineMesh.ToTF) + sphereRadius);
 }
Esempio n. 4
0
    public float GetDistance(SplineWalker car)
    {
        var steps = 50;
        var from  = this.progress;
        var to    = car.progress;

        if (to >= from)
        {
            return(spline.GetPathLength(steps, from, to));
        }
        return(spline.GetPathLength((int)(steps / 2), from, 1f) + spline.GetPathLength((int)(steps / 2), 0f, to));
    }
Esempio n. 5
0
 // Use this for initialization
 IEnumerator Start()
 {
     Walker = GetComponent <SplineWalker>();
     // As usual: Wait for the spline
     while (!Walker.Spline.IsInitialized)
     {
         yield return(null);
     }
     // register for the OnGetScale event of the MeshBuilder
     SplineMesh.OnGetScale += new SplinePathMeshBuilder.OnGetScaleEvent(SplineMesh_OnGetScale);
     // store min/max TF where we have to change the scale of the mesh
     meshMinTF = SplineMesh.Spline.DistanceToTF(SplineMesh.Spline.TFToDistance(SplineMesh.FromTF) - sphereRadius);
     meshMaxTF = SplineMesh.Spline.DistanceToTF(SplineMesh.Spline.TFToDistance(SplineMesh.ToTF) + sphereRadius);
 }
Esempio n. 6
0
    private void Start()
    {
        spline   = GetComponent <SplineWalker>();
        duration = spline.duration;
        GetComponent <Collider>().isTrigger = true;

        //Changes the animation curve based on duration value
        Keyframe[] keyframes = escapeSpeedCurve.keys;

        keyframes[0].value = duration;
        keyframes[1].value = duration * 0.2f;
        keyframes[2].value = duration + 1;

        escapeSpeedCurve.keys = keyframes;
    }
Esempio n. 7
0
    public SplineWalker GetClosest()
    {
        var          cars        = GetCars();
        SplineWalker closest     = null;
        float        closestDiff = 0;

        foreach (var car in cars)
        {
            var diff = GetDistance(car);
            if (closest == null || diff < closestDiff)
            {
                closest     = car;
                closestDiff = diff;
            }
        }
        return(closest);
    }
Esempio n. 8
0
	// Use this for initialization
	void Start () {
#if USE_REVMOB_ANDROID
		//for ads
		RevMobBanner banner = revmob.CreateBanner();
		banner.Show();
#endif
		string[] tubes = {
			"Tube01", "Tube02", "Tube03", "Tube04", "Tube05", "Tube06", "Tube07" 
		};
		arrButton [0] = GameObject.Find ("Bt_Camera").GetComponent<Button>();
		arrButton [1] = GameObject.Find ("Bt_eye").GetComponent<Button>();
		arrButton [2] = GameObject.Find ("Bt_foot").GetComponent<Button>();
		arrButton [3] = GameObject.Find ("Bt_infor").GetComponent<Button>();
		listRadius = new float[tubes.Length];
		for (int i = 0; i < tubes.Length; i++) {
			GameObject obj = GameObject.Find(tubes[i]);
			CircleCollider2D circleCollider2D = obj.GetComponent<CircleCollider2D>();
			listRadius[i] = circleCollider2D.radius*circleCollider2D.transform.localScale.x*transform.localScale.x;
		}
		arrLimitPoints [0] = new Vector3 (0, listRadius [2], 0);
		arrLimitPoints [1] = new Vector3 (0, -listRadius [2], 0);
		arrLimitPoints [2] = new Vector3 (listRadius [2], 0, 0);
		arrLimitPoints [3] = new Vector3 (-listRadius [2], 0, 0);
		for (int i = 0; i < darts.Length; i++) {
			darts[i] = Instantiate (objectDart) as GameObject;	
		}
		Target = darts [0];
		splineWalker = Target.GetComponent <SplineWalker> ();
		SplineWalker.listRadius = listRadius;
		SplineWalker.remainScoreText = remainScoreText;
		SplineWalker.textGetScore = textGetScore;
		tmpV = Target.transform.position - splineWalker.spline.transform.position;
		oldpositionTarget = Target.transform.position;
		oldRotationTarget = Target.transform.localEulerAngles;
		oldScaleTarget = Target.transform.localScale;
		oldRotationSpline = splineWalker.spline.transform.localEulerAngles;
		oldPostionnSpline = splineWalker.spline.transform.position;
		GameObject objCam = GameObject.Find ("Main Camera");
		oldPostionCamera = objCam.transform.position;
		oldAnglesCamera = objCam.transform.eulerAngles;
		cam = objCam.camera;
		cam.transform.LookAt(GameObject.Find ("ObjectBoard").transform.position);
		oldLookAt = GameObject.Find ("ObjectBoard").transform.position;
		splineWalkerCam = objCam.GetComponent <SplineWalker> ();
	}
Esempio n. 9
0
    public void Init()
    {
        Walker = GetComponent <SplineWalker>();
        Pather = GetComponent <CarPather>();

        Walker.Mode = SplineWalkerMode.Once;
        Pather.Init();

        Walker.Duration = MaxSpeed;
        lastPosition    = gameObject.transform.position;

        Material mat = GetComponent <MeshRenderer>().material;

        if (NonAPICar)
        {
            mat.SetColor("_Color", Color.red);
        }
    }
Esempio n. 10
0
    public void OnTriggerEnter(Collider other)
    {
        //Debug.LogFormat("Entered the the railing {0}", other.name);
        Animator anim = other.GetComponent <Animator>();

        anim.SetBool("Rail", true);
        anim.applyRootMotion = false;
        //locally check
        colliderToLocallyDisable.enabled = false;

        SplineWalker newSpline = other.gameObject.AddComponent <SplineWalker>();

        newSpline.spline      = spline;
        newSpline.duration    = length;
        newSpline.lookForward = true;
        newSpline.mode        = SplineWalkerMode.Once;
        timeStarted           = Time.time;

        if (!playersOnMe.Contains(other.gameObject))
        {
            playersOnMe.Add(other.gameObject);
        }
    }
Esempio n. 11
0
    // Use this for initialization
    void Start()
    {
        if (walker == null)
        {
            walker = GetComponent <SplineWalker>();
        }

        rotateController = GetComponent <RotateController>();

        //init delegates
        if (onOne != null)
        {
            walker.onOne += onOne.Invoke;
        }
        if (onZero != null)
        {
            walker.onZero += onZero.Invoke;
        }
        if (onMid != null)
        {
            walker.onMid += onMid.Invoke;
        }
    }
Esempio n. 12
0
    public void UpdateAim()
    {
        float step = aimSpeed * Time.deltaTime;
        // roatate to look at

        //transform.LookAt(target);
        Vector3 movementPrediction = Vector3.zero;

        if (target.GetComponentInParent <SplineWalker>())
        {
            SplineWalker myWalker = target.GetComponentInParent <SplineWalker>();
            // target velocity           *      Time to target  = distance
            movementPrediction = (myWalker.velocity * myWalker.spline.GetDirection(myWalker.progress)) * (Vector3.Distance(target.position, transform.position) / BulletSpeedCompensation);
        }
        Quaternion temp = Quaternion.LookRotation(transform.position - (target.position + (movementPrediction)));// get the current speed of the vehicle AND the current speed of your head

        transform.rotation = Quaternion.RotateTowards(transform.rotation, temp, step);

        /*
         * RaycastHit hit;
         * Physics.Raycast(transform.position, -transform.forward, out hit, 100, lm);
         * myLineRenderer.SetPosition(0, transform.position);
         *
         * if (hit.collider != null && hit.collider.CompareTag("Player"))
         * {
         *  AimisGood = true;
         *  myLineRenderer.SetPosition(1, hit.point);
         *  Debug.Log("AimIsGood");
         * }
         * else
         * {
         *  AimisGood = false;
         *  myLineRenderer.SetPosition(1, -transform.forward * 100);
         * }
         */
        AimisGood = true;
    }
    private void Awake()
    {
        if (frequency <= 0 || items == null || items.Length == 0)
        {
            return;
        }
        float stepSize = frequency * items.Length;

        if (spline.Loop || stepSize == 1)
        {
            stepSize = 1f / stepSize;
        }
        else
        {
            stepSize = 1f / (stepSize - 1);
        }
        for (int p = 0, f = 0; f < frequency; f++)
        {
            for (int i = 0; i < items.Length; i++, p++)
            {
                Transform item = Instantiate(items [i]) as Transform;
                //custom
                walker        = item.GetComponent <SplineWalker>();
                walker.spline = spline;
                //Spaceing along the bezier: f is incrementor, Don't devide by zero!!!!
                item.GetComponent <SplineWalker>().progress = 1f / (frequency * (items.Length + 1)) * f;
                Debug.Log("f" + f.ToString() + " is " + (stepSize * f).ToString());
                //Vector3 position = spline.GetPoint (p * stepSize);
                //item.transform.localPosition = position;
                if (lookForward)
                {
                    item.transform.LookAt(spline.GetPoint(p * stepSize) + spline.GetDirection(p * stepSize));
                }
                walker = null;
            }
        }
    }
 private void SetComponents()
 {
     titleWalker = titleText.GetComponent <SplineWalker>();
     m_animator  = GetComponent <Animator>();
 }
Esempio n. 15
0
            public void Update()
            {
                if (firstRun)
                {
                    firstRun = false;

                    var start = piece.gameObject.transform.position;
                    var diffVector = destination - start;

                    if (isTeleport)
                    {
                        curveMult = 100f;
                    }

                    var secondControl = (diffVector * 0.2f) + (curveHeight * diffVector.magnitude * curveMult) + start;
                    var thirdControl = (diffVector * 0.8f) + (curveHeight * diffVector.magnitude * curveMult) + start;

                    moveSpline.SetControlPoint(0, start);
                    moveSpline.SetControlPoint(1, secondControl);
                    moveSpline.SetControlPoint(2, thirdControl);
                    moveSpline.SetControlPoint(3, destination);

                    walker = piece.gameObject.AddComponent<SplineWalker>();
                    walker.spline = moveSpline;
                    walker.duration = moveTime;
                    walker.lookForward = false;
                    walker.mode = SplineWalkerMode.Once;
                }

                //if (Vector3.Distance(piece.gameObject.transform.position, destination) < 0.01)
                if(walker.progress > 0.99)
                {
                    piece.gameObject.transform.position = destination;
                    Complete = true;
                    Destroy(walker);
                    finishedMoving.Dispatch(piece);
                }
            }
    public override void OnInspectorGUI()
    {
        m_Walker = target as SplineWalker;

        serializedObject.Update();

        m_Walker.m_Spline = (BezierSpline)EditorGUILayout.ObjectField(m_Walker.m_Spline, typeof(BezierSpline), true);

        if (!(m_Walker.m_Spline == null))
        {
            CheckRenderer();

            int splineCurves = m_Walker.m_Spline.CurveCount;
            if (m_Walker.m_WalkerSplinePoints.Count == 0)
            {
                m_Walker.AlignToNewSpline(m_Walker.m_Spline);
            }
            else if (m_Walker.m_WalkerSplinePoints.Count != m_Walker.m_Spline.CurveCount)
            {
                m_Walker.ResizeToSpline();
            }

            ////SplineWalkerTester
            //labelStyle.alignment = TextAnchor.UpperCenter;
            //labelStyle.fontStyle = FontStyle.Bold;
            //EditorGUILayout.LabelField("Walker Motion Tester", labelStyle);
            //if (GUILayout.Button(new GUIContent("Play/Pause"), EditorStyles.miniButton))
            //{
            //    if (!m_Walker.m_walking)
            //    {
            //        m_Walker.StartWalking();
            //    }
            //    else
            //    {
            //        m_Walker.PauseWalking();
            //    }
            //}

            //Set Up Styles
            var labelStyle = GUI.skin.GetStyle("Label");
            labelStyle.fontStyle = FontStyle.Normal;

            //Spline Summary
            EditorGUILayout.BeginHorizontal();

            labelStyle.fontStyle = FontStyle.Bold;
            EditorGUILayout.LabelField("Total Curves: ", GUILayout.Width(80f));
            EditorGUILayout.LabelField(splineCurves.ToString(), labelStyle, GUILayout.Width(30f));
            EditorGUILayout.LabelField("Total Time: ", GUILayout.Width(80f));
            EditorGUILayout.LabelField(m_Walker.TotalTime().ToString(), GUILayout.Width(30f));

            EditorGUILayout.EndHorizontal();

            //InitialPosition
            EditorGUILayout.LabelField("Initial Spline Position");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("m_initialSplinePos"), GUIContent.none);
            if (!Application.isPlaying)
            {
                m_Walker.SetPosToInitial();
            }

            //Auto functionality
            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.LabelField("Auto Walk", GUILayout.Width(63f));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("m_autoWalk"), GUIContent.none, GUILayout.Width(15f));
            EditorGUILayout.LabelField("Auto Reset", GUILayout.Width(66f));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("m_autoReset"), GUIContent.none, GUILayout.Width(15f));
            EditorGUILayout.LabelField("Auto Kill", GUILayout.Width(55f));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("m_destroyAtEnd"), GUIContent.none, GUILayout.Width(15f));

            EditorGUILayout.EndHorizontal();

            //Speed functionality
            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.LabelField("Vary Speed", GUILayout.Width(70f));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("m_variableSpeed"), GUIContent.none, GUILayout.Width(15f));
            EditorGUILayout.LabelField("Spd Type", GUILayout.Width(60f));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("m_speedType"), GUIContent.none, GUILayout.Width(100f));

            EditorGUILayout.EndHorizontal();


            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.LabelField("Rotation", GUILayout.Width(60f));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("m_rotationType"), GUIContent.none, GUILayout.Width(60f));
            if (m_Walker.m_rotationType == WalkerRotationType.Angle || m_Walker.m_rotationType == WalkerRotationType.Velocity)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("m_rotationAxis"), GUIContent.none, GUILayout.Width(60f));
                if (m_Walker.m_rotationType == WalkerRotationType.Angle)
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("m_angleOffset"), GUIContent.none, GUILayout.Width(60f));
                }
            }
            else if (m_Walker.m_rotationType == WalkerRotationType.Target && !m_Walker.m_variableSpeed)
            {
                m_Walker.m_lookTarget = (GameObject)EditorGUILayout.ObjectField(m_Walker.m_lookTarget, (typeof(GameObject)), true);
            }

            EditorGUILayout.EndHorizontal();


            if (!m_Walker.m_variableSpeed)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PropertyField(serializedObject.FindProperty("m_walkSpeed"));
                EditorGUILayout.EndHorizontal();
            }
            else
            {
                //Current Curve Editor
                labelStyle.alignment = TextAnchor.UpperCenter;
                labelStyle.fontStyle = FontStyle.Bold;
                EditorGUILayout.LabelField("Curve Editor", labelStyle);
                currentCurve = EditorGUILayout.IntSlider(currentCurve, 0, splineCurves - 1);

                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button(new GUIContent("<"), EditorStyles.miniButtonLeft))
                {
                    currentCurve -= 1;
                    currentCurve  = currentCurve < 0 ? splineCurves - 1 : currentCurve;
                }
                labelStyle           = GUI.skin.GetStyle("Label");
                labelStyle.alignment = TextAnchor.UpperCenter;
                EditorGUILayout.LabelField(currentCurve.ToString(), labelStyle, GUILayout.Width(30f));
                if (GUILayout.Button(new GUIContent(">"), EditorStyles.miniButtonRight))
                {
                    currentCurve += 1;
                    currentCurve  = currentCurve > splineCurves - 1 ? 0 : currentCurve;
                }
                EditorGUILayout.EndHorizontal();

                //Current point to edit
                EditorGUILayout.PropertyField(
                    serializedObject.FindProperty("m_WalkerSplinePoints").GetArrayElementAtIndex(currentCurve),
                    GUIContent.none);

                //Duplicate point
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button(new GUIContent("Duplicate Left"), EditorStyles.miniButton))
                {
                    m_Walker.DuplicatePoint(currentCurve, currentCurve - 1);
                }
                if (GUILayout.Button(new GUIContent("Duplicate Right"), EditorStyles.miniButton))
                {
                    m_Walker.DuplicatePoint(currentCurve, currentCurve + 1);
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button(new GUIContent("Duplicate All"), EditorStyles.miniButton))
                {
                    m_Walker.DuplicateAllPoints(currentCurve);
                }
                if (GUILayout.Button(new GUIContent("Duplicate To Idx:"), EditorStyles.miniButton, GUILayout.Width(120f)))
                {
                    m_Walker.DuplicatePoint(currentCurve, m_Walker.m_duplicationIdx);
                }
                EditorGUILayout.PropertyField(serializedObject.FindProperty("m_duplicationIdx"), GUIContent.none);
                EditorGUILayout.EndHorizontal();

                //All Points
                ShowArrayProperty(serializedObject.FindProperty("m_WalkerSplinePoints"),
                                  "Curve ");
                //EditorGUILayout.PropertyField(serializedObject.FindProperty("m_WalkerSplinePoints"),true);
            }
        }
        serializedObject.ApplyModifiedProperties();
    }
 void OnEnable()
 {
     m_Walker = target as SplineWalker;
 }
Esempio n. 18
0
	void Update () {
		if (cameraMode == CameraMode.ZoomBoard) {
			UpdateZoomBoard ();
			return;
		} else if (cameraMode == CameraMode.ReviewBoard) {
			if(!SplineWalker.reviewCamera){
				updateCameraReviewBoard ();
				return;
			}
		}
		else if(cameraMode == CameraMode.MoveBoard){
			updateCameraMoveBoard ();
			return;
		}
		Debug.Log ("cameraMode ------------------------------------------- " + cameraMode);
		if (cameraMode != CameraMode.ReviewDarts || SplineWalker.isThrowingDart) {
			_mouseState = false;
			return;
		}
		/*if (Input.mousePosition.y < 140 && (Input.mousePosition.x < 60 || Input.mousePosition.x > Screen.width - 60)) {
			if(_mouseState) {
				Target.SetActive(false);
				_mouseState = false;
			}
			return;
		}*/
		if (Input.GetMouseButtonDown (0)) {
			if(SplineWalker.resetDart) {
				SplineWalker.resetDart = false;
				resetAllDarts();
			}
			Target = darts[SplineWalker.s_count];
			splineWalker = Target.GetComponent <SplineWalker> ();
			if(splineWalker.isThrowEdDart) return;
			splineWalker.spline.transform.localEulerAngles = oldRotationSpline;
			splineWalker.spline.transform.position = oldPostionnSpline;
			Target.SetActive(true);
			_mouseState = true;
			oldMouse = Input.mousePosition;
			screenSpace = Camera.main.WorldToScreenPoint (Target.transform.position);
			Target.transform.position = Camera.main.ScreenToWorldPoint (new Vector3 (Input.mousePosition.x, Input.mousePosition.y, screenSpace.z));

		}
		if (Input.GetMouseButtonUp (0)) {
			if(!Target.activeSelf || !_mouseState) return;
			_mouseState = false;
			float d = Vector2.Distance(Input.mousePosition, oldMouse);
			if(d > 5 && Input.mousePosition.y > oldMouse.y) {
				Vector2 v1 = new Vector2(0, 1);
				Vector2 v2 = new Vector2(Input.mousePosition.x - oldMouse.x, Input.mousePosition.y - oldMouse.y);
				float angle = Vector2.Angle(v1, v2);
				splineWalker.spline.transform.Rotate(new Vector3(0, 0, 1), (Input.mousePosition.x > oldMouse.x ? -angle : angle));
				splineWalker.spline.transform.position = Target.transform.position - tmpV;
				splineWalker.isThrowDart = true;
			} else {
				Target.SetActive(false);
			}
		}
		if (_mouseState) {
			//keep track of the mouse position
			var curScreenSpace = new Vector3 (Input.mousePosition.x, Input.mousePosition.y, screenSpace.z);
			
			//convert the screen mouse position to world point and adjust with offset
			var curPosition = Camera.main.ScreenToWorldPoint (curScreenSpace);
			
			//update the position of the object in the world
			Target.transform.position = new Vector3(curPosition.x, curPosition.y+1f,curPosition.z);
		}
	}
Esempio n. 19
0
    public override void OnInspectorGUI()
    {
        walker = target as SplineWalker;
        // display all normal stuff first

        // assigned spline
        EditorGUI.BeginChangeCheck();
        BezierSpline spline = (BezierSpline)EditorGUILayout.ObjectField(walker.spline, typeof(BezierSpline), true);

        //SplineWalker walker = (SplineWalker)EditorGUILayout.EnumPopup("spline mode: ", walker.mode)

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(walker, "Spline");
            EditorUtility.SetDirty(walker);
            walker.spline = spline;
        }

        //looking foreward
        EditorGUI.BeginChangeCheck();
        bool lookForeward = EditorGUILayout.Toggle("lookForeward", walker.lookForward);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(walker, "Toggle lookForeward");
            EditorUtility.SetDirty(walker);
            walker.lookForward = lookForeward;
        }
        // fixed duration
        EditorGUI.BeginChangeCheck();
        bool fixedDuration = EditorGUILayout.Toggle("FixedDuration", walker.fixedDuration);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(walker, "Toggle fixedDuration");
            EditorUtility.SetDirty(walker);
            walker.fixedDuration = fixedDuration;
        }
        //movement mode
        EditorGUI.BeginChangeCheck();
        SplineWalkerMode mode = (SplineWalkerMode)EditorGUILayout.EnumFlagsField("Mode", walker.mode);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(walker, "Mode");
            EditorUtility.SetDirty(walker);
            walker.mode = mode;
        }
        //show the going foreward bool
        EditorGUI.BeginChangeCheck();
        bool goingForeward = EditorGUILayout.Toggle("goingForeward", walker.goingForeward);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(walker, "Toggle goingForeward");
            EditorUtility.SetDirty(walker);
            walker.goingForeward = goingForeward;
        }

        // does this walker have a fixed duration
        if (walker.fixedDuration)
        {
            // show the duration
            EditorGUI.BeginChangeCheck();
            float duration = EditorGUILayout.FloatField("Duration", walker.duration);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(walker, "Duration");
                EditorUtility.SetDirty(walker);
                walker.duration = duration;
            }
        }
        else
        {
            //show the velocity field
            EditorGUI.BeginChangeCheck();
            float velocity = EditorGUILayout.FloatField("velocity", walker.velocity);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(walker, "velocity");
                EditorUtility.SetDirty(walker);
                walker.velocity = velocity;
            }
        }
        // base.OnInspectorGUI();
    }
Esempio n. 20
0
	public Vector3 getInCenterOfDarts(){
		SplineWalker[] splineWalkers = new SplineWalker[3];
		Vector3[] pos = new Vector3[3];
		splineWalkers[0] = darts [0].GetComponent <SplineWalker> ();
		splineWalkers[1] = darts [1].GetComponent <SplineWalker> ();
		splineWalkers[2] = darts [2].GetComponent <SplineWalker> ();
		int count = 0;
		for (int i = 0; i < splineWalkers.Length; i++) {
			if (!splineWalkers[i].dartOutScreen){
				pos[i] = darts [i].transform.position;
				count++;
			} else {
				pos[i] = Vector3.zero;
			}
		}

		switch(count) {
		case 3:
			float a = Vector3.Distance (pos [1], pos [2]);
			float b = Vector3.Distance (pos [0], pos [2]);
			float c = Vector3.Distance (pos [0], pos [1]);
			distanceMax2Target = Mathf.Max(a, b, c);
			float P = a + b + c;
			Vector3 result = new Vector3 ((a * pos [0].x + b * pos [1].x + c * pos [2].x) / P,
			                              (a * pos [0].y + b * pos [1].y + c * pos [2].y) / P,
			                              pos [0].z);
			Vector3 v1 = Vector3.zero;
			Vector3 v2 = Vector3.zero;
			Vector3 midpoint = Vector3.zero;
			if(distanceMax2Target == a) {
				v1 = pos [2] - pos [1];
				midpoint = (pos[1] + pos[2]) / 2;
			} else if(distanceMax2Target == b){
				v1 = pos [2] - pos [0];
				midpoint = (pos[0] + pos[2]) / 2;
			} else if(distanceMax2Target == c){
				v1 = pos [1] - pos [0];
				midpoint = (pos[0] + pos[1]) / 2;
			}
			v2 = new Vector3(-v1.y, v1.x, pos[0].z);
			float a1 = v1.x, b1 = v1.y, c1 = -(a1*midpoint.x + b1*midpoint.y);
			float a2 = v2.x, b2 = v2.y, c2 = -(a2*result.x + b2*result.y);
			float x = (c2*b1-c1*b2)/(a1*b2-a2*b1);
			float y = -(c2*a1-c1*a2)/(a1*b2-a2*b1);
			return new Vector3(x, y, pos [0].z);
		case 2:
			Vector3[] p = new Vector3[2];
			int num = 0;
			for (int i = 0; i < splineWalkers.Length; i++) {
				if (!splineWalkers[i].dartOutScreen) {
					p[num++] = pos[i];
				}
			}
			distanceMax2Target = Vector3.Distance(p[0], p[1]);
			return new Vector3((p[0].x + p[1].x)/2, (p[0].y + p[1].y)/2, p[0].z);
		case 1:
			for (int i = 0; i < splineWalkers.Length; i++) {
				if (!splineWalkers[i].dartOutScreen) {
					return pos[i];
				}
			}
			break;
		default:
			break;
		};
		return GameObject.Find ("ObjectBoard").transform.position;
	}
	// Use this for initialization
	void Start () {
        walkerScript = GetComponent<SplineWalker>();
        mMat = renderer.material;
	}
 private void SetComponents()
 {
     m_Animator     = GetComponent <Animator>();
     m_SplineWalker = GetComponent <SplineWalker>();
 }
Esempio n. 23
0
 // Use this for initialization
 void Start()
 {
     walkerScript = GetComponent <SplineWalker>();
     mMat         = GetComponent <Renderer>().material;
 }
Esempio n. 24
0
 private void setAsLeftSpawn(SplineWalker child)
 {
     setAsRightSpawn(child);
     child.offset = new Vector3(-child.offset.x, child.offset.y, child.offset.z);
 }
Esempio n. 25
0
 private void setAsRightSpawn(SplineWalker child)
 {
     var thisSize = GetComponent<SpriteRenderer>().bounds.size;
     var xOffset = thisSize.x / 2f;
     child.offset = new Vector3(xOffset, -thisSize.y, 0);
 }
 private void SetComponents()
 {
     m_Walker = GetComponent <SplineWalker>();
 }
 private void SetComponents()
 {
     m_CinematicAnimator = GetComponent <Animator>();
     m_SplineWalker      = GetComponent <SplineWalker>();
     m_AudioSource       = GetComponent <AudioSource>();
 }
Esempio n. 28
0
 /// <summary>
 /// Cache the SplineWalker and flag context for clean serialization when joining late.
 /// </summary>
 private void Awake()
 {
     this.SplineWalker = this.GetComponent <SplineWalker>();
     this.m_firstTake  = true;
 }
Esempio n. 29
0
 // Start is called before the first frame update
 void Start()
 {
     myHealth   = GetComponentInParent <PlayerHealth>();
     myWalker   = GetComponentInParent <SplineWalker>();
     lastHealth = myHealth.health;
 }