Esempio n. 1
0
 private static void ResourcesOfUI()
 {
     ResBase.Suffixs.Clear();
     ResBase.Suffixs.Add(FileSystem.key_suffix_prefab);
     ResBase.RootPath = PathSystem.GetReservedPrefabRoot(PathType.absPath);
     ResourceMap2File.Add2AllResources(ResBase.GetNamesOfPath(false, "*", false, string.Empty));
     ResBase.Suffixs.Clear();
     ResBase.Suffixs.Add(FileSystem.key_suffix_prefab);
     ResBase.RootPath = PathSystem.GetUIPrefabRoot(PathType.absPath);
     ResourceMap2File.Add2AllResources(ResBase.GetNamesOfPath(false, "*", false, string.Empty));
     ResBase.Suffixs.Clear();
     ResBase.Suffixs.Add(FileSystem.key_suffix_prefab);
     ResBase.RootPath = PathSystem.GetUI3DPrefabRoot(PathType.absPath);
     ResourceMap2File.Add2AllResources(ResBase.GetNamesOfPath(false, "*", false, string.Empty));
     ResBase.Suffixs.Clear();
     ResBase.Suffixs.Add(FileSystem.key_suffix_prefab);
     ResBase.RootPath = PathSystem.GetReservedPrefabRoot(PathType.absPath);
     ResourceMap2File.Add2AllResources(ResBase.GetNamesOfPath(false, "*", false, string.Empty));
     ResBase.Suffixs.Clear();
     ResBase.Suffixs.Add(FileSystem.key_suffix_material);
     ResBase.RootPath = PathSystem.GetUI3DPrefabRoot(PathType.absPath);
     ResourceMap2File.Add2AllResources(ResBase.GetNamesOfPath(true, "*", false, string.Empty));
     ResBase.Suffixs.Clear();
     ResBase.Suffixs.Add(FileSystem.key_suffix_controller);
     ResBase.RootPath = PathSystem.GetUIAnimRoot(PathType.absPath);
     ResourceMap2File.Add2AllResources(ResBase.GetNamesOfPath(false, "*", false, string.Empty));
     ResBase.Suffixs.Clear();
     ResBase.Suffixs.Add(FileSystem.key_suffix_prefab);
     ResBase.RootPath = PathSystem.GetSpineRoot(PathType.absPath);
     ResourceMap2File.Add2AllResources(ResBase.GetNamesOfPath(true, "*", false, FileSystem.key_suffix_spine));
 }
Esempio n. 2
0
 private static void ResourcesOfAnimatorController()
 {
     ResBase.Suffixs.Clear();
     ResBase.Suffixs.Add(".controller");
     ResBase.RootPath = PathSystem.GetActorAnimationRoot(PathType.absPath);
     ResourceMap2File.Add2AllResources(ResBase.GetNamesOfPath(false, "*", false, string.Empty));
 }
Esempio n. 3
0
 private static void ResourcesOffxs()
 {
     ResBase.Suffixs.Clear();
     ResBase.Suffixs.Add(".prefab");
     ResBase.RootPath = PathSystem.GetGameEffectPrefabRoot(PathType.absPath);
     ResourceMap2File.Add2AllResources(ResBase.GetNamesOfPath(false, "*", false, string.Empty));
 }
Esempio n. 4
0
 private static void ResourcesOfSceneLightmaps()
 {
     ResBase.Suffixs.Clear();
     ResBase.Suffixs.Add(".prefab");
     ResBase.RootPath = PathSystem.GetSceneRoot(PathType.absPath);
     ResourceMap2File.Add2AllResources(ResBase.GetNamesOfPath(false, "s*", false, string.Empty));
 }
Esempio n. 5
0
 private static void ResourcesOfShaders()
 {
     ResBase.Suffixs.Clear();
     ResBase.Suffixs.Add(".prefab");
     ResBase.RootPath = PathSystem.GetShaderPrefabRoot(PathType.absPath);
     ResourceMap2File.Add2AllResources(ResBase.GetNamesOfPath(true, "*", false, ".shader"));
 }
Esempio n. 6
0
    private void ProcessInVesselPointerOver()
    {
        foreach (GameObject go in _InVesselPointerOver)
        {
            if (Input.GetKeyDown(KeyCode.Mouse0))
            {
                GameObjectManager.setGameObjectLayer(go, 11); // Now macrophage is considered as an immunity cell
                MoveToward move     = go.GetComponent <MoveToward>();
                Playable   playable = go.GetComponent <Playable>();
                if (playable)
                {
                    //Global.data.trackedEntities.
                    foreach (PairEStatTrackedEntityInt trackedEntity in Global.data.trackedEntities)
                    {
                        if (trackedEntity.a == playable.trackedEntity)
                        {
                            trackedEntity.b++;
                            break;
                        }
                    }
                }
                GameObject target = PathSystem.GetClosestWaypoint(go, _Waypoints);

                GameObjectManager.addComponent(go, typeof(PathFollower), new
                {
                    destination = PathSystem.ComputeDestination(target.transform.position, _EndWaypoints)
                });                                      // Compute destination (the closest one from start waypoint)

                move.target = target.transform.position; // Move cell to closest waypoint
            }
        }
    }
Esempio n. 7
0
 private void Init()
 {
     PathSystem.Init();
     if (Application.get_isPlaying() && Application.get_isEditor())
     {
         string text = Application.get_dataPath() + "/StreamingAssets/resources2json.txt";
     }
     Object.DontDestroyOnLoad(base.get_gameObject());
     FileSystem.Init();
     PreloadUIBaseSystem.Init();
     GamePackets.Register();
     base.InvokeRepeating("Tick", 0f, 0.03f);
     Loom.Current.Init();
     this.InitBugly();
     base.get_gameObject().AddComponent <RemoteLogSender>();
     if (GameManager.IsDebug)
     {
         return;
     }
     CamerasMgr.CameraUI.set_enabled(false);
     this.OpenPreloadingUI();
     PreloadingUIView.SetProgressName("正在初始化环境...");
     Screen.set_sleepTimeout(-1);
     Debug.Log("SystemInfo.deviceModel = " + SystemInfoTools.GetDeviceModel());
     this.CurrentUpdateManager = new UpdateManager();
     this.CurrentUpdateManager.Init();
     this.CheckUpdate();
 }
Esempio n. 8
0
 private static void ResourcesOfAudios()
 {
     ResBase.Suffixs.Clear();
     ResBase.Suffixs.Add(".wav");
     ResBase.Suffixs.Add(".mp3");
     ResBase.RootPath = PathSystem.GetAudioRoot(PathType.absPath);
     ResourceMap2File.Add2AllResources(ResBase.GetNamesOfPath(false, "*", false, string.Empty));
 }
Esempio n. 9
0
    public static string GetPath(PathType type, string u3dPathOfnoasset)
    {
        switch (type)
        {
        case PathType.absPath:
            return(Application.get_dataPath() + u3dPathOfnoasset);

        case PathType.u3dPath_no_assets:
            return(u3dPathOfnoasset);

        case PathType.u3dPath_has_asset:
        {
            string path = PathSystem.GetPath(PathType.absPath, u3dPathOfnoasset);
            return(path.Substring(path.IndexOf("Assets")));
        }

        case PathType.resourcesPath:
            if (u3dPathOfnoasset.Contains("/Resources/"))
            {
                return(u3dPathOfnoasset.Substring("/Resources/".get_Length()));
            }
            PathSystem.ShowError();
            return(string.Empty);

        case PathType.SubPackageInfo:
            return(Path.Combine(Environment.get_CurrentDirectory(), string.Format("SubPackageInfo/{0}", u3dPathOfnoasset)));

        case PathType.ApkPath:
            return(PathUtil.Combine(new string[]
            {
                PathSystem.ApkDir,
                u3dPathOfnoasset
            }));

        case PathType.ApkPatchPath:
            return(PathUtil.Combine(new string[]
            {
                PathSystem.ApkPatchDir,
                u3dPathOfnoasset
            }));

        case PathType.ResPatch:
            return(PathUtil.Combine(new string[]
            {
                PathSystem.PersistentDataPath,
                "resPatch",
                u3dPathOfnoasset
            }));

        default:
            return(string.Empty);
        }
    }
Esempio n. 10
0
    private static void ResourcesOfTPAtlas()
    {
        ResBase.Suffixs.Clear();
        ResBase.Suffixs.Add(".png");
        ResBase.Suffixs.Add(".jpg");
        ResBase.Suffixs.Add(".PNG");
        ResBase.Suffixs.Add(".JPG");
        ResBase.RootPath = PathSystem.GetSrcSpriteRoot(PathType.absPath);
        ResourceMap2File.Add2AllResources(ResBase.GetNamesOfFolder(true, true));
        ResBase.Suffixs.Clear();
        ResBase.Suffixs.Add(".png");
        ResBase.Suffixs.Add(".jpg");
        ResBase.Suffixs.Add(".PNG");
        ResBase.Suffixs.Add(".JPG");
        ResBase.RootPath = PathSystem.GetSrcSpriteRGBRoot(PathType.absPath);
        ResourceMap2File.Add2AllResources(ResBase.GetNamesOfFolder(true, true));
        ResBase.Suffixs.Clear();
        ResBase.Suffixs.Add(".prefab");
        ResBase.RootPath = PathSystem.GetTPAtlasRoot(PathType.absPath);
        Hashtable namesOfPath = ResBase.GetNamesOfPath(true, "*", true, string.Empty);

        ResourceMap2File.Add2AllResources(namesOfPath);
        string      text       = string.Empty;
        IEnumerator enumerator = namesOfPath.get_Keys().GetEnumerator();

        try
        {
            while (enumerator.MoveNext())
            {
                object current = enumerator.get_Current();
                string text2   = current.ToString();
                text2 = text2.Substring(0, text2.get_Length() - "_pb".get_Length());
                text  = text + text2 + ';';
            }
        }
        finally
        {
            IDisposable disposable = enumerator as IDisposable;
            if (disposable != null)
            {
                disposable.Dispose();
            }
        }
        ResourceMap2File.AllResources.set_Item("UiAtlas_KEY", text);
        ResBase.Suffixs.Clear();
        ResBase.Suffixs.Add(".prefab");
        ResBase.RootPath = PathSystem.GetReservedPrefabRoot(PathType.absPath);
        namesOfPath      = ResBase.GetNamesOfPath(true, "*", true, string.Empty);
        ResourceMap2File.Add2AllResources(namesOfPath);
    }
        public static bool TryLoadText(PathSystem pathSystem, string path, string extension, out string text)
        {
            switch (pathSystem)
            {
            default:
            case PathSystem.DirectPath:
                return(TryLoadTextFromPatch(path + extension, out text));

            case PathSystem.StreamingAssets:
                return(TryLoadTextFromStreamingAssets(path + extension, out text));

            case PathSystem.Resources:
                return(TryLoadTextFromRessource(path, out text));
            }
        }
        public static bool TrySaveText(PathSystem pathSystem, string path, string extension, string text)
        {
            switch (pathSystem)
            {
            default:
            case PathSystem.DirectPath:
                return(TrySaveTextToPatch(path + extension, text));

            case PathSystem.StreamingAssets:
                return(TrySaveTextToStreamingAssets(path + extension, text));

            case PathSystem.Resources:
                return(false);
            }
        }
Esempio n. 13
0
 private static void ResourcesOfTexture()
 {
     ResBase.Suffixs.Clear();
     ResBase.Suffixs.Add(".png");
     ResBase.Suffixs.Add(".jpg");
     ResBase.Suffixs.Add(".tga");
     ResBase.Suffixs.Add(".psd");
     ResBase.RootPath = PathSystem.GetTextureRGBARoot(PathType.absPath);
     ResourceMap2File.Add2AllResources(ResBase.GetNamesOfPath(true, "*", false, string.Empty));
     ResBase.RootPath = PathSystem.GetTextureRGBRoot(PathType.absPath);
     ResourceMap2File.Add2AllResources(ResBase.GetNamesOfPath(true, "*", false, string.Empty));
     ResBase.RootPath = PathSystem.GetTextureShaderRoot(PathType.absPath);
     ResourceMap2File.Add2AllResources(ResBase.GetNamesOfPath(true, "*", false, string.Empty));
     ResBase.RootPath = PathSystem.GetReservedPrefabRoot(PathType.absPath);
     ResourceMap2File.Add2AllResources(ResBase.GetNamesOfPath(true, "*", false, string.Empty));
 }
Esempio n. 14
0
    // Update is called once per frame
    void Update()
    {
        if (selectedItem != null)
        {
            Cursor.SetCursor(selectedItem.icon, Vector2.zero, CursorMode.Auto);
        }
        else
        {
            Cursor.SetCursor(basePointer, Vector2.zero, CursorMode.Auto);
        }

        //if we click the mouse
        if (Input.GetMouseButtonDown(1) && !EventSystem.current.IsPointerOverGameObject())
        {
            //make a raycast from the camera to the world
            Ray        clickRay = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit clickHit; //this holds information about what we clicked on
            //fire the raycast and retrieve the data
            if (Physics.Raycast(clickRay, out clickHit))
            {
                //if we hit an interactable
                if (clickHit.transform.GetComponent <Interactable>())
                {
                    //interact
                    //Debug.Log("Interactable");
                    //pass our current action to the interactable and retrieve a response
                    //lastResponse = clickHit.transform.GetComponent<Interactable>().Interact(currentAction);
                    currentTarget = clickHit.transform.GetComponent <Interactable>(); //we're going to store the interactable as our target
                }
                else if (clickHit.transform.GetComponent <PathSystem>())              //If we've clicked on something with a path system (the backdrop)
                {
                    //vector3 point
                    clickedPoint = clickHit.point;                                 //we'll want this soon
                    PathSystem p = clickHit.transform.GetComponent <PathSystem>(); //Store a reference to the path system for convenience
                    //pass to avatar
                    Vector3 point = p.PathPoint(clickedPoint.x);                   //get the end point of the path from the path system by providing the click
                    avatar.SetPath(p.path, point);                                 //pass the path to our avatar as well as the end point
                }
            }
            UpdateUI();
        }
    }
Esempio n. 15
0
 public void Initialize(Action <string> loadFailed = null)
 {
     AssetLoader.useDynamicLoader = true;
     this.LoadFailed = loadFailed;
     if (Application.get_isEditor())
     {
         if (Directory.Exists(PathSystem.GetEditorDataDir()))
         {
             AppConst.ResourcePath = PathSystem.GetEditorDataDir();
         }
         this.InitPackageFileList();
     }
     if (this.m_assetName2abInfoMap == null)
     {
         this.m_assetName2abInfoMap = SerializeUtility.DeserializeXDictFromMemory <string, AssetBundleInfo>(XUtility.GetConfigTxt("abmap", ".txt"));
     }
     this.m_manifest = (AssetLoader.LoadAssetNow("AssetBundleManifest", typeof(AssetBundleManifest)) as AssetBundleManifest);
     if (this.m_manifest == null)
     {
         Debug.LogError("manifest加载失败");
     }
 }
    public void Start()
    {
        // TODO: This is a stupid hack because this system is half-assed
        foreach (var og in FindObjectsOfType <OrbitGroup>())
        {
            og.Position();
        }

        // TODO: kind of a hacky way to set courses for all these predictive chasers
        foreach (var chaser in FindObjectsOfType <PredictiveChaser>())
        {
            float  tf = 3f;
            float3 p0 = chaser.transform.position;
            float3 v0 = InitialHeading * InitialSpeed;
            float3 pf = FuturePosition(chaser.Target, tf);
            float3 vf = FutureVelocity(chaser.Target, tf);

            chaser.TimeElapsed = 0;
            chaser.Trajectory  = PathSystem.TrajectoryFrom(tf, p0, v0, pf, vf);
        }

        Emitters    = FindObjectsOfType <Emitter>().ToList();
        FreeBodies  = FindObjectsOfType <FreeBody>().ToList();
        Travelers   = FindObjectsOfType <Traveler>().ToList();
        Orbiters    = FindObjectsOfType <Orbiter>().ToList();
        Velocities  = FindObjectsOfType <Velocity>().ToList();
        DeathTimers = FindObjectsOfType <DeathTimer>().ToList();

        Rotators         = FindObjectsOfType <Rotator>();
        Geosynchronouses = FindObjectsOfType <Geosynchronous>();
        OrbitPredictors  = FindObjectsOfType <OrbitPredictor>();
        TargetReflectors = FindObjectsOfType <TargetReflector>();
        LightSources     = FindObjectsOfType <LightSource>();
        NormalizedMasses = FindObjectsOfType <NormalizedMass>();
        SkyHookRockets   = FindObjectsOfType <SkyHookRocket>();
    }
Esempio n. 17
0
    private void MakeDecision()
    {
        foreach (GameObject go in _Active)
        {
            Macrophage  macrophage = go.GetComponent <Macrophage>();
            MoveToward  move       = go.GetComponent <MoveToward>();
            Triggered3D triggered  = go.GetComponent <Triggered3D>();

            bool shouldRecompute = false;

            // Is the a pathogene nearby ?
            if (triggered != null)
            {
                Eater      eater            = go.GetComponent <Eater>();
                float      minDistance      = float.MaxValue;
                GameObject targetedPosition = null;

                // Compute closest eatable thing
                foreach (GameObject target in triggered.Targets)
                {
                    Eatable eatable = target.GetComponent <Eatable>();
                    if (eatable != null && (eatable.eatableMask & eater.eatingMask) > 0)
                    {
                        float distance = Vector3.Distance(go.transform.position, target.transform.position);
                        if (distance < minDistance)
                        {
                            minDistance      = distance;
                            targetedPosition = target;
                        }
                    }
                }

                if (targetedPosition != null) // Found something to eat
                {
                    // Move to it
                    move.target = targetedPosition.transform.position;

                    // Update last decision made
                    macrophage.lastDescision = DECISIONS.CHASE;

                    continue;
                }

                if (macrophage.lastDescision.Equals(DECISIONS.CHASE)) // Last decision was chase but nothing is eatable in our range
                {
                    shouldRecompute = true;                           // We need to recompute a path to the closest EndNode.
                }
            }

            if (macrophage.lastDescision.Equals(DECISIONS.CHASE) || shouldRecompute) // No pathogene to hunt in the area
            {
                // Recompute closest Waypoint
                GameObject   _target  = PathSystem.GetClosestWaypoint(go, _Waypoints);
                PathFollower follower = go.GetComponent <PathFollower>();

                // Update destination
                follower.destination = PathSystem.ComputeDestination(_target.transform.position, _EndWaypoints);
                move.target          = _target.transform.position;

                // Update decision
                macrophage.lastDescision = DECISIONS.FOLLOW_PATH;
            }
        }
    }
Esempio n. 18
0
 private string GetResPatchPath(UpdateManager.ResPathDir type, string version)
 {
     return(PathSystem.GetPath(PathType.ResPatch, this.GetResPatchRelPath(type, version)));
 }
Esempio n. 19
0
 private string GetResPatchConfigPath()
 {
     return(PathSystem.GetPath(PathType.ResPatch, this.GetResPatchRelPath(UpdateManager.ResPathDir.config, string.Empty)));
 }
Esempio n. 20
0
 private string GetResPatchDir(UpdateManager.ResPathDir type)
 {
     return(PathSystem.GetPath(PathType.ResPatch, type.ToString()));
 }
Esempio n. 21
0
 public static string GetGameDataCsRoot(PathType type)
 {
     return(PathSystem.GetPath(type, PathSystem.RootOfU3DNoAssets.GameDataCsRoot));
 }
Esempio n. 22
0
 public static string GetActorAnimationRoot(PathType type)
 {
     return(PathSystem.GetPath(type, PathSystem.RootOfU3DNoAssets.RootOfActorAnimation));
 }
Esempio n. 23
0
 public static string GetActorPrefabRoot(PathType type)
 {
     return(PathSystem.GetPath(type, PathSystem.RootOfU3DNoAssets.RootOfActorPrefab));
 }
    public void FixedUpdate()
    {
        float dt = Time.fixedDeltaTime;

        foreach (var emitter in Emitters)
        {
            emitter.TimeTillEmission -= dt;

            if (emitter.TimeTillEmission <= 0)
            {
                GameObject emittee = Instantiate(emitter.Emittee, emitter.transform.position, emitter.transform.rotation);

                Register(emittee);
                if (emittee.TryGetComponent <Velocity>(out Velocity v))
                {
                    v.Value = emitter.transform.forward * emitter.EmissionSpeed;
                }
                // TODO: note... this is not totally correct as we could slightly overshoot...
                // TODO: consider fixing this AND the initial position based on this slight overshoot to get perfect behavior
                emitter.TimeTillEmission = emitter.EmissionPeriod;
            }
        }

        // Update deathtimers: modifies component arrays
        for (int i = 0; i < DeathTimers.Count; i++)
        {
            DeathTimer deathTimer = DeathTimers[i];

            deathTimer.Value -= dt;
            if (deathTimer.Value <= 0)
            {
                UnRegister(deathTimer.gameObject);
                Destroy(deathTimer.gameObject);
                i--;
            }
        }

        // Update all free bodies
        foreach (var freebody in FreeBodies)
        {
            Velocity v = freebody.GetComponent <Velocity>();

            foreach (var normalizedMass in NormalizedMasses)
            {
                float3 delta     = normalizedMass.transform.position - freebody.transform.position;
                float3 direction = normalize(delta);
                float  d         = length(delta);

                v.Value += direction * dt * normalizedMass.Value * MassFactor * G / (d * d);
            }
        }

        // There are several versions of this system that will offer better and better behavior
        // The stupid chaser with fixed speed
        //      Constantly tries to move towards the CURRENT location of their target
        foreach (var chaser in FindObjectsOfType <Chaser>())
        {
            float3 delta             = chaser.Target.position - chaser.transform.position;
            float3 direction         = normalize(chaser.Target.position - chaser.transform.position);
            float  remainingDistance = min(length(delta), chaser.MaxSpeed * dt);

            chaser.transform.position = chaser.transform.position + remainingDistance * (Vector3)direction;
            Debug.DrawLine(chaser.transform.position, chaser.Target.position, Color.red);
        }

        // The predictive chaser
        //      Predicts the location of the target various times in the future
        //      Chooses the first time where the distance to the object is within its range for that given time based on its max speed
        //      Moves towards that future location at the required speed
        var predictiveChasers = FindObjectsOfType <PredictiveChaser>();

        foreach (var predictiveChaser in predictiveChasers)
        {
            predictiveChaser.TimeElapsed       += dt;
            predictiveChaser.transform.position = PathSystem.PositionFromTrajectoryAtTime(predictiveChaser.Trajectory, predictiveChaser.TimeElapsed);
        }
        foreach (var predictiveChaser in predictiveChasers)
        {
            if (predictiveChaser.TimeElapsed >= predictiveChaser.Trajectory.duration)
            {
                predictiveChaser.transform.SetParent(predictiveChaser.Target, true);
                predictiveChaser.transform.localPosition = Vector3.zero;
                Destroy(predictiveChaser);
            }
        }

        foreach (var traveler in Travelers)
        {
            // every traveler needs to calculate the position of their target
        }

        // Set the required radius of all orbiters that are geosynchronous
        foreach (var geosynchronous in Geosynchronouses)
        {
            if (geosynchronous.TryGetComponent <Orbiter>(out Orbiter orbiter))
            {
                const float MASS = 1;

                orbiter.Radius = Orbiter.RequiredRadiusForPeriod(MASS, G, geosynchronous.Rotator.Period);
            }
        }

        // Update all orbiters
        foreach (var orbiter in Orbiters)
        {
            // TODO: This mass value is stubbed out here but probably should be taken from the body itself?
            const float MASS   = 1;
            float       period = Orbiter.Period(orbiter, MASS, G);

            orbiter.Radians = (orbiter.Radians + (float)orbiter.Direction * TWO_PI / period * dt) % (TWO_PI);
            orbiter.transform.localPosition = orbiter.Radius * UnitCircle(orbiter.Radians);
        }

        // Update all rotators
        foreach (var rotator in Rotators)
        {
            rotator.Radians = (rotator.Radians + (float)rotator.Direction * TWO_PI / rotator.Period * dt) % (TWO_PI);
            rotator.transform.localRotation = Quaternion.AngleAxis(-rotator.Radians * Mathf.Rad2Deg, Vector3.up);
        }

        // Update all target reflectors
        foreach (var targetreflector in TargetReflectors)
        {
            float3 toSource = targetreflector.Source.transform.position - targetreflector.transform.position;
            float3 toTarget = targetreflector.Target.transform.position - targetreflector.transform.position;
            float3 halfway  = normalize((normalize(toSource) + normalize(toTarget)) / 2);

            targetreflector.transform.forward = halfway;
        }

        // Update Skyhook Rockets
        foreach (var skyhookRocket in SkyHookRockets)
        {
            switch (skyhookRocket.CurrentPlan)
            {
            case SkyHookRocket.Plan.EnterOrbit:
                skyhookRocket.TimeRemaining -= dt;

                if (skyhookRocket.TimeRemaining <= 0)
                {
                    Orbiter o = (Orbiter)skyhookRocket.gameObject.AddComponent(typeof(Orbiter));

                    o.Radians   = 0;
                    o.Radius    = skyhookRocket.orbitRadius;
                    o.Direction = Orbiter.RotationalDirection.CounterClockwise;
                    Orbiters.Add(o);
                    skyhookRocket.TimeRemaining = 0;
                    skyhookRocket.transform.SetParent(skyhookRocket.Origin, true);
                    skyhookRocket.CurrentPlan = SkyHookRocket.Plan.RideTheHook;
                }
                else
                {
                    float3 currentPosition = skyhookRocket.transform.position;
                    float3 futurePosition  = FuturePosition(skyhookRocket.Origin, skyhookRocket.TimeRemaining);
                    float  fraction        = skyhookRocket.TimeRemaining / skyhookRocket.TransitionTime;

                    Debug.DrawLine(currentPosition, futurePosition, Color.red);
                    skyhookRocket.TimeRemaining     -= dt;
                    skyhookRocket.transform.position = lerp(futurePosition, currentPosition, fraction);
                }

                break;

            case SkyHookRocket.Plan.RideTheHook:
                // Check if we should release
                if (Input.GetKeyDown(KeyCode.Space))
                {
                    float3   trajectory = FutureVelocity(skyhookRocket.transform, 0);
                    Orbiter  orbiter    = skyhookRocket.GetComponent <Orbiter>();
                    Velocity velocity   = (Velocity)skyhookRocket.gameObject.AddComponent(typeof(Velocity));

                    Orbiters.Remove(orbiter);
                    Velocities.Add(velocity);
                    Destroy(orbiter);
                    velocity.Value = trajectory;
                    skyhookRocket.transform.SetParent(null, true);
                    skyhookRocket.transform.forward = normalize(trajectory);
                    skyhookRocket.CurrentPlan       = SkyHookRocket.Plan.Free;
                }
                break;
            }
        }

        foreach (var velocity in Velocities)
        {
            velocity.transform.position += dt * (Vector3)velocity.Value;
        }

        foreach (var orbitPredictor in OrbitPredictors)
        {
            int count = orbitPredictor.LineRenderer.positionCount;
            for (int i = 0; i < count; i++)
            {
                float  time          = (float)i / (float)(count - 1) * OrbitPredictorTimeInTheFuture;
                float3 velocity      = FutureVelocity(orbitPredictor.transform, 0);
                float3 trajectory    = normalize(velocity);
                float3 toTarget      = new float3(0, 0, 0) - (float3)orbitPredictor.transform.position;
                float3 towardsTarget = normalize(toTarget);
                float  trajectoryDotTowardsTarget = dot(trajectory, towardsTarget);

                orbitPredictor.LineRenderer.SetPosition(i, FuturePosition(orbitPredictor.transform, time));
            }
        }

        // Raytracing for light sources
        RaytracingSystem.LightSources     = LightSources;
        RaytracingSystem.LightSourceCount = RaytracingSystem.LightSources.Length;
        RaytracingSystem.Schedule();

        // Raytrace rendering
        for (int i = 0; i < RaytracingSystem.Traces.Count; i++)
        {
            var trace         = RaytracingSystem.Traces[i];
            var lr            = LineRenderers[i];
            var logEnergy     = pow(trace.Energy, ScalePower);
            var width         = EnergyToWidthCurve.Evaluate(logEnergy);
            var intensity     = EnergyToIntensityCurve.Evaluate(logEnergy);
            var emissionColor = intensity * BeamColor;

            lr.positionCount = 2;
            lr.SetPosition(0, trace.From);
            lr.SetPosition(1, trace.To);
            lr.startWidth = width;
            lr.endWidth   = width;
            lr.material.SetColor("Color", BeamColor);
            lr.material.SetColor("_EmissionColor", emissionColor);
            lr.gameObject.SetActive(true);
        }
        for (int i = RaytracingSystem.Traces.Count; i < LineRenderers.Length; i++)
        {
            LineRenderers[i].gameObject.SetActive(false);
        }

        // Render orbits
        OrbitRenderingSystem.Orbiters = Orbiters;
        OrbitRenderingSystem.Count    = OrbitRenderingSystem.Orbiters.Count;
        OrbitRenderingSystem.Schedule();

        // Update the spacefield
        SpaceField.NormalizedMasses = NormalizedMasses;
        SpaceField.Count            = SpaceField.NormalizedMasses.Length;
        SpaceField.Schedule();
    }
Esempio n. 25
0
 public static string GetSubPackageInfoPath(string fileName)
 {
     return(PathSystem.GetPath(PathType.SubPackageInfo, fileName));
 }
Esempio n. 26
0
 public static string GetGameEffectPrefabRoot(PathType type)
 {
     return(PathSystem.GetPath(type, PathSystem.RootOfU3DNoAssets.GameEffectPrefabRoot));
 }
Esempio n. 27
0
 private string GetNewPatchPath()
 {
     return(PathSystem.GetPath(PathType.ApkPatchPath, this.GetNewPatchName()));
 }
Esempio n. 28
0
 // Use this for initialization
 void Start()
 {
     Debug.Log("Runtime platform: " + PathSystem.GetPlatformStr());
 }
Esempio n. 29
0
 private string GetPatchInfoPath()
 {
     return(PathSystem.GetPath(PathType.ApkPatchPath, PathSystem.ApkPatchInfoFileName));
 }
Esempio n. 30
0
 public static string GetSceneRoot(PathType type)
 {
     return(PathSystem.GetPath(type, PathSystem.RootOfU3DNoAssets.RootOfScene));
 }