Inheritance: MonoBehaviour
示例#1
0
    // Orient the collidable objects
    public override void Orient(PlatformObject parent, Vector3 position, Quaternion rotation)
    {
        base.Orient(parent, position, rotation);

        platformParent = parent;
        platformParent.OnPlatformDeactivation += CollidableDeactivation;
    }
示例#2
0
        // spawn the platforms, obstacles, power ups, and coins
        private PlatformObject SpawnObjects(ObjectLocation location, Vector3 position, Vector3 direction, bool activateImmediately)
        {
            SetupSection(location, false);
            spawnData.turnSpawned = turnPlatform[(int)location] != null;
            int localIndex = infiniteObjectManager.GetNextObjectIndex(ObjectType.Platform, spawnData);

            if (localIndex == -1)
            {
                print("Unable to spawn platform. No platforms can be spawned based on the probability rules at distance " +
                      infiniteObjectHistory.GetTotalDistance(false) + " within section " + spawnData.section + (spawnData.sectionTransition ? (" (Transitioning from section " + spawnData.prevSection + ")") : ""));
                return(null);
            }
            PlatformObject platform = SpawnPlatform(localIndex, location, position, direction, activateImmediately);

            if (platform.CanSpawnCollidable() && Random.value >= noCollidableProbability.GetValue(infiniteObjectHistory.GetTotalDistance(false)))
            {
                // First try to spawn an obstacle. If there is any space remaining on the platform, then try to spawn a coin.
                // If there is still some space remaing, try to spawn a powerup.
                // An extension of this would be to randomize the order of ObjectType, but this way works if the probabilities
                // are setup fairly
                SpawnCollidable(ObjectType.Obstacle, position, direction, location, platform, localIndex, activateImmediately);
                if (platform.CanSpawnCollidable())
                {
                    SpawnCollidable(ObjectType.Coin, position, direction, location, platform, localIndex, activateImmediately);
                    if (platform.CanSpawnCollidable())
                    {
                        SpawnCollidable(ObjectType.PowerUp, position, direction, location, platform, localIndex, activateImmediately);
                    }
                }
            }

            return(platform);
        }
示例#3
0
    // Spawn platform
    private PlatformObject SpawnPlatform(int localIndex, Direction locationDirection, Vector3 position,
                                         Vector3 direction, bool activateImmediately)
    {
        PlatformObject platform     = (PlatformObject)ObjectPool.instance.GetObjectFromPool(localIndex, ObjectType.Platform);
        Quaternion     lookRotation = Quaternion.LookRotation(direction);

        platform.Orient(position + (direction * platformSizes[localIndex].z / 2), lookRotation);
        if (activateImmediately)
        {
            platform.Activate();
        }

        int         objectIndex     = ObjectPool.instance.GetObjectIndexFromLocalIndex(localIndex, ObjectType.Platform);
        BasicObject prevTopPlatform = ObjectHistory.instance.ObjectSpawned(objectIndex, 0, locationDirection,
                                                                           lookRotation.eulerAngles.y, ObjectType.Platform, platform);

        // the current platform now becames the parent of the previous top platform
        if (prevTopPlatform != null)
        {
            prevTopPlatform.SetObjectParent(platform);
        }
        else
        {
            ObjectHistory.instance.SetBottomObject(locationDirection, IS_PLATFORM, platform);
        }
        ObjectHistory.instance.AddTotalDistance(platformSizes[localIndex].z, locationDirection, IS_PLATFORM, spawnData.section);

        return(platform);
    }
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        PlatformObject platformObject = (PlatformObject)target;

        bool sectionTransition = EditorGUILayout.Toggle("Is Section Transition", platformObject.sectionTransition);

        if (sectionTransition != platformObject.sectionTransition)
        {
            platformObject.sectionTransition = sectionTransition;
            EditorUtility.SetDirty(target);
        }

        if (sectionTransition)
        {
            List <int> fromSection = platformObject.fromSection;
            List <int> toSection   = platformObject.toSection;
            if (SectionSelectionInspector.showSectionTransitions(ref fromSection, ref toSection))
            {
                platformObject.fromSection = fromSection;
                platformObject.toSection   = toSection;
                EditorUtility.SetDirty(target);
            }
        }
    }
示例#5
0
        // returns the length of the created platform
        private PlatformObject SpawnPlatform(int localIndex, ObjectLocation location, Vector3 position, Vector3 direction, bool activateImmediately)
        {
            PlatformObject platform     = (PlatformObject)infiniteObjectManager.ObjectFromPool(localIndex, ObjectType.Platform);
            Quaternion     lookRotation = Quaternion.LookRotation(direction);

            platform.Orient(position + (direction * platformSizes[localIndex].z / 2), lookRotation);
            if (activateImmediately)
            {
                platform.Activate();
            }

            int            objectIndex     = infiniteObjectManager.LocalIndexToObjectIndex(localIndex, ObjectType.Platform);
            InfiniteObject prevTopPlatform = infiniteObjectHistory.ObjectSpawned(objectIndex, 0, location, lookRotation.eulerAngles.y, ObjectType.Platform, platform);

            // the current platform now becames the parent of the previous top platform
            if (prevTopPlatform != null)
            {
                prevTopPlatform.SetInfiniteObjectParent(platform);
            }
            else
            {
                infiniteObjectHistory.SetBottomInfiniteObject(location, false, platform);
            }
            infiniteObjectHistory.AddTotalDistance(platformSizes[localIndex].z, location, false, spawnData.section);

            return(platform);
        }
示例#6
0
    // Reset values
    public void ResetValues()
    {
        isFlying        = false;
        isFlyingPending = false;
        flySpeed        = 0;

        isStumbling       = false;
        onGround          = true;
        prevHitHashCode   = -1;
        canUpdatePosition = true;
        playerAnimation.ResetValues();
        turnTime = -simultaneousTurnPreventionTime;

        platformObject = null;

        currentSlotPosition      = SlotPosition.Center;
        targetHorizontalPosition = (int)currentSlotPosition * ObjectGenerator.instance.slotDistance;
        totalMoveDistance        = 0;
        curveOffset = Vector3.zero;
        turnOffset  = prevTurnOffset = Vector3.zero;
        forwardSpeeds.ResetValues();

        thisTransform.position = startPosition;
        thisTransform.rotation = startRotation;
        targetRotation         = startRotation;
        UpdateTargetPosition(targetRotation.eulerAngles.y);
    }
示例#7
0
    public override void orient(PlatformObject parent, Vector3 position, Quaternion rotation)
    {
        base.orient(parent, position, rotation);

        collideWithPlayer = true;
        moving = (startMoveSquaredDistance == 0);
        lastSquareMagnitude = Mathf.Infinity;
        yAngle = thisTransform.eulerAngles.y;
    }
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        GUILayout.Space(10);

        CollidableAppearanceRules collidableAppearanceRules = (CollidableAppearanceRules)target;
        List<PlatformPlacementRule> platformPlacementRules = collidableAppearanceRules.avoidPlatforms;
        if (PlatformPlacementRuleInspector.showPlatforms(ref platformPlacementRules, false)) {
            collidableAppearanceRules.avoidPlatforms = platformPlacementRules;
            EditorUtility.SetDirty(target);
        }
        
        if (addNewAvoidPlatform) {
            GUILayout.BeginHorizontal();
            GUILayout.Label("Target Platform");
            targetPlatform = EditorGUILayout.ObjectField(targetPlatform, typeof(PlatformObject), false) as PlatformObject;
            GUILayout.EndHorizontal();

            if (addError.Length > 0) {
                GUI.contentColor = Color.red;
                GUILayout.Label(addError);
                GUI.contentColor = Color.white;
            }

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Add")) {
                int error;
                if ((error = PlatformPlacementRuleInspector.addPlatform(platformPlacementRules, targetPlatform, false)) == 0) {
                    addNewAvoidPlatform = false;
                    EditorUtility.SetDirty(target);
                } else {
                    switch (error) {
                        case 1:
                            addError = "Error: Target Platform is not set";
                            break;
                        case 2:
                            addError = "Error: Target Platform has already been added";
                            break;
                        default:
                            addError = "Unknown Error";
                            break;
                    }
                }
            }

            if (GUILayout.Button("Cancel")) {
                addNewAvoidPlatform = false;
            }
            GUILayout.EndHorizontal();
        }

        if (!addNewAvoidPlatform && GUILayout.Button("Add Avoid Platform")) {
            addError = "";
            addNewAvoidPlatform = true;
        }
    }
示例#9
0
 private void Update()
 {
     if (player.position.x > firstPlatform.transform.position.x + despawnDistance)
     {
         PlatformObject platform = platformPool.Pop(DetermineSpawnPosition(lastPlatform));
         Add(platform);
         Remove(firstPlatform);
     }
 }
示例#10
0
    private Vector3 DetermineSpawnPosition(PlatformObject lastPlat)
    {
        float minX = lastPlat.width + lastPlat.width;

        float y = lastPlat.transform.position.y + Random.Range(-yGap, yGap);
        float x = lastPlatform.transform.position.x + minX + Random.Range(0f, xGap);

        return(new Vector3(x, Random.Range(-yGap, yGap), 0f));
    }
示例#11
0
    // orient for collidables which have a platform as a parent
    public virtual void orient(PlatformObject parent, Vector3 position, Quaternion rotation)
    {
        thisTransform.parent = parent.getTransform();
        Vector3 pos = startPosition;

        pos += position;
        thisTransform.localPosition = parent.getTransform().InverseTransformPoint(pos);
        thisTransform.rotation      = startRotation;
        thisTransform.Rotate(0, rotation.eulerAngles.y, 0, Space.World);
    }
示例#12
0
    // Override to add additional restriction
    public override bool CanSpawnObject(float distance, ObjectSpawnData spawnData)
    {
        if (!base.CanSpawnObject(distance, spawnData))
        {
            return(false);
        }

        int platformLocalIndex = ObjectHistory.instance.GetFirstPlatformIndex();

        if (platformLocalIndex == -1)
        {
            return(false);
        }

        // Get the platform that this scene is going to spawn next to.
        // See if the platform requires linked scenes and if it does, if this scene fulfills that requirement.
        PlatformObject platform = ObjectPool.instance.GetObjectFromLocalIndex(platformLocalIndex, ObjectType.Platform) as PlatformObject;

        if (platform.HasLinkedScenes())
        {
            for (int i = 0; i < linkedPlatforms.Count; ++i)
            {
                if (linkedPlatforms[i].CanSpawnObject(platformLocalIndex))
                {
                    return(true);
                }
            }
            return(false);
        }
        else if (linkedPlatforms.Count > 0)             // return false if this scene is linked to a platform but the platform doesn't have any linked scenes
        {
            return(false);
        }

        // if the platform can't fit, then don't spawn it
        float totalDistance = ObjectHistory.instance.GetTotalDistance(false);
        float largestScene  = spawnData.largestScene;
        float sceneBuffer   = (spawnData.useWidthBuffer ? platformSceneWidthBuffer : 0);       // useWidthBuffer contains the information if we should spawn up to totalDistance

        if (totalDistance - distance - sceneBuffer - largestScene >= 0)
        {
            // largest scene of 0 means we are approaching a turn and it doesn't matter what size object is spawned as long as it fits
            if (largestScene == 0)
            {
                return(totalDistance - distance - sceneBuffer >= zSize);
            }
            else
            {
                return(largestScene >= zSize);
            }
        }

        return(false);
    }
    // An object run contains many platforms strung together with collidables: obstacles, power ups, and coins. If spawnObjectRun encounters a turn,
    // it will spawn the objects in the correct direction
    public void spawnObjectRun(bool activateImmediately)
    {
        while (localDistance[(int)ObjectLocation.Center] < horizon && turnPlatform[(int)ObjectLocation.Center] == null)
        {
            PlatformObject platform = spawnObjects(ObjectLocation.Center, localDistance[(int)ObjectLocation.Center] * moveDirection + localPlatformHeight[(int)ObjectLocation.Center] * Vector3.up + turnOffset,
                                                   moveDirection, activateImmediately);
            if (platform == null)
            {
                return;
            }

            platformSpawned(platform, ObjectLocation.Center, moveDirection, Vector3.zero, activateImmediately);

            if (spawnFullLength)
            {
                spawnObjectRun(activateImmediately);
            }
        }

        if (turnPlatform[(int)ObjectLocation.Center] != null)
        {
            Vector3 turnDirection = turnPlatform[(int)ObjectLocation.Center].getTransform().right;

            // spawn the platform and scene objects for the left and right turns
            for (int i = 0; i < 2; ++i)
            {
                ObjectLocation location = (i == 0 ? ObjectLocation.Right : ObjectLocation.Left);

                bool canTurn = (location == ObjectLocation.Right && turnPlatform[(int)ObjectLocation.Center].isRightTurn) ||
                               (location == ObjectLocation.Left && turnPlatform[(int)ObjectLocation.Center].isLeftTurn);
                if (canTurn && turnPlatform[(int)location] == null)
                {
                    infiniteObjectHistory.setActiveLocation(location);
                    Vector3 centerDistance = (localDistance[(int)ObjectLocation.Center] + turnPlatform[(int)ObjectLocation.Center].turnLengthOffset) * moveDirection;
                    if (localDistance[(int)location] < horizon)
                    {
                        PlatformObject platform = spawnObjects(location, centerDistance + turnDirection * localDistance[(int)location] + localPlatformHeight[(int)location] * Vector3.up + turnOffset,
                                                               turnDirection, activateImmediately);
                        if (platform == null)
                        {
                            return;
                        }

                        platformSpawned(platform, location, turnDirection, centerDistance, activateImmediately);
                    }
                }
                turnDirection *= -1;
            }

            // reset
            infiniteObjectHistory.setActiveLocation(ObjectLocation.Center);
        }
    }
示例#14
0
    private void Start()
    {
        PlatformObject platform = platformPool.Pop(startingPlatform.transform.position);

        firstPlatform = platform;
        lastPlatform  = platform;

        for (int i = 0; i < startingCount; i++)
        {
            Add(platformPool.Pop(DetermineSpawnPosition(lastPlatform)));
        }
    }
示例#15
0
    /// <summary>
    /// Places an object on a platform
    /// </summary>
    /// <param name="platformObject">The object to place</param>
    /// <param name="platform">The platform to place it on</param>
    protected virtual void PlacePlatformObject(PlatformObject platformObject, Transform platform)
    {
        var obsPool = platformObject.pool;
        var obj     = obsPool.GetFromPool();

        var pos = platform.position + Vector3.up * platform.GetComponent <BoxCollider>().size.y;

        obj.position = pos;
        obj.rotation = Quaternion.Euler(0, 180, 0);

        PlatformsPlacedOnThisFrame.Add(platform);
    }
示例#16
0
    void ShowNextMap(PlatformObject currentMap)
    {
        var aux = currentMap.Combinations.Where(c => !c.Visible).ToArray();

        var nextMap = aux[rnd.Next(0, aux.Length)];

        var v = currentMap.Instance.transform.position +
                new Vector3(0, currentMap.Instance.transform.GetChild(0).GetComponent <SpriteRenderer>().bounds.size.y,
                            0);

        ActivateMap(nextMap, v);
    }
示例#17
0
    // Orient for objects relative to parent
    public virtual void Orient(PlatformObject parent, Vector3 position, Quaternion rotation)
    {
        thisTransform.parent = parent.GetTransform();
        Vector3 pos    = Vector3.zero;
        float   yAngle = rotation.eulerAngles.y;

        pos.Set(startPosition.x * Mathf.Cos(yAngle * Mathf.Deg2Rad) + startPosition.z * Mathf.Sin(yAngle * Mathf.Deg2Rad), startPosition.y,
                -startPosition.x * Mathf.Sin(yAngle * Mathf.Deg2Rad) + startPosition.z * Mathf.Cos(yAngle * Mathf.Deg2Rad));
        pos += position;
        thisTransform.localPosition = parent.GetTransform().InverseTransformPoint(pos);
        thisTransform.rotation      = startRotation;
        thisTransform.Rotate(0, rotation.eulerAngles.y, 0, Space.World);
    }
示例#18
0
        public Vector3 GetTurnOffset()
        {
            // add an offset so the character is always in the correct slot after a turn
            PlatformObject topPlatform      = infiniteObjectHistory.GetTopInfiniteObject(ObjectLocation.Center, false) as PlatformObject;
            Vector3        offset           = Vector3.zero;
            Vector3        position         = topPlatform.GetTransform().position;
            int            topPlatformIndex = infiniteObjectHistory.GetLastLocalIndex(ObjectLocation.Center, ObjectType.Platform);
            Quaternion     lookRotation     = Quaternion.LookRotation(spawnDirection);

            offset.x = (position.x + platformStartPosition[topPlatformIndex].x * (spawnDirection.z > 0 ? -1 : 1)) * -Mathf.Cos(lookRotation.eulerAngles.y * Mathf.Deg2Rad) * (spawnDirection.z > 0 ? -1 : 1);
            offset.z = (position.z + platformStartPosition[topPlatformIndex].x * (spawnDirection.x < 0 ? -1 : 1)) * Mathf.Sin(lookRotation.eulerAngles.y * Mathf.Deg2Rad) * (spawnDirection.x < 0 ? -1 : 1);
            return(offset);
        }
示例#19
0
        public void ResetValues(bool fromRevive)
        {
            StopSlide(true);
            slideData.duration   = 0;
            stumbleData.duration = 0;

            jumpSpeed         = 0;
            isJumping         = false;
            isJumpPending     = false;
            isSliding         = false;
            isStumbling       = false;
            onGround          = true;
            prevHitTransform  = null;
            canUpdatePosition = true;
            playerAnimation.ResetValues();
            if (projectileManager)
            {
                projectileManager.ResetValues();
            }
            pauseCollisionParticlePlaying = false;
            turnTime     = -simultaneousTurnPreventionTime;
            jumpLandTime = Time.time;

            platformObject        = null;
            curveTime             = -1;
            curveMoveDistance     = 0;
            curveDistanceMapIndex = 0;
            followCurve           = false;

            if (!fromRevive)
            {
                currentSlotPosition      = SlotPosition.Center;
                targetHorizontalPosition = (int)currentSlotPosition * infiniteObjectGenerator.slotDistance;
                totalMoveDistance        = 0;
                turnOffset  = prevTurnOffset = Vector3.zero;
                curveOffset = Vector3.zero;
                forwardSpeeds.ResetValues();

                thisTransform.position = startPosition;
                thisTransform.rotation = startRotation;
                targetRotation         = startRotation;
                UpdateTargetPosition(targetRotation.eulerAngles.y);
                reviveTime = -1;
            }
            else
            {
                reviveTime = Time.time;
            }
        }
示例#20
0
    public void RestartGame()
    {
        mainMenu.SetActive(true);
        gameStarted  = false;
        gameOver     = false;
        playerActive = false;

        // Reset the positions of the objects
        for (int i = 0; i < gameElements.Count; i++)
        {
            PlatformObject element = gameElements [i];
            element.ResetToInitialPosition();
        }
        player.ResetToStartPosition();
    }
        public override void AssignIndexToObject(InfiniteObject infiniteObject, int index)
        {
            base.AssignIndexToObject(infiniteObject, index);

            for (int i = 0; i < linkedPlatforms.Count; ++i)
            {
                if (linkedPlatforms[i].AssignIndexToObject(infiniteObject, index))
                {
                    PlatformObject platform = infiniteObject as PlatformObject;
                    platform.EnableLinkedSceneObjectRequired();
                    (thisInfiniteObject as SceneObject).sectionTransition = platform.sectionTransition;
                    break;
                }
            }
        }
示例#22
0
    // Assign index for object
    // This also has the responsibility of adding indices for the linked platform
    public override void AssignIndexToObject(BasicObject targetObject, int index)
    {
        base.AssignIndexToObject(targetObject, index);

        for (int i = 0; i < linkedPlatforms.Count; ++i)
        {
            if (linkedPlatforms[i].AssignIndexToObject(targetObject, index))
            {
                PlatformObject platform = targetObject as PlatformObject;
                platform.EnableLinkScenes();
                (thisObject as SceneObject).isForSectionTransition = platform.isForSectionTransition;
                break;
            }
        }
    }
    protected override void OnCollision(Collider2D collider, Vector2 contactPosition)
    {
        GameObject collidedObject = collider.gameObject;
        string     layerName      = LayerMask.LayerToName(collidedObject.layer);
        string     tagName        = collidedObject.tag;

        if (ceilingCollision)
        {
            if (jumpVarTimer < jumpVarTime - jumpVarCeilingGrace)
            {
                jumpVarTimer = 0;
            }
        }

        if (grounded)
        {
            if (tagName == "Platform")
            {
                PlatformObject platformScript = collidedObject.GetComponent <PlatformObject>();

                if (!platformScript.movingPlatform)
                {
                    OnLanded();
                }

                if (platformScript.disappearingPlatform)
                {
                    platformScript.BeginDisappear();
                }
            }
            else
            {
                cameraController.SetVerticalState(CameraController.VerticalState.PositionLock);
                lastLandedPlatformHeight = float.NegativeInfinity;
            }

            animator.SetBool("Jumping", false);
        }
        else if (layerName == "Enemy")
        {
            OnHit(collider, contactPosition);
        }
        else if (layerName == "Trap")
        {
            OnDeath();
        }
    }
示例#24
0
    // returns true if there is still space on the platform for a collidable object to spawn
    private void SpawnCollidable(ObjectType objectType, Vector3 position, Vector3 direction, Direction locationDirection,
                                 PlatformObject platform, int platformLocalIndex, bool activateImmediately)
    {
        int collidablePositions = platform.numCollidables;

        // can't do anything if the platform doesn't accept any collidable object spawns
        if (collidablePositions == 0)
        {
            return;
        }

        Vector3 offset = platformSizes[platformLocalIndex] * 0.1f;
        float   zDelta = platformSizes[platformLocalIndex].z * .8f / (1 + collidablePositions);

        for (int i = 0; i < collidablePositions; ++i)
        {
            if (platform.CanSpawnCollidable(i))
            {
                spawnData.slotPositions = platform.GetSlotsAvailable();
                int localIndex = ObjectPool.instance.GetNextObjectIndex(objectType, spawnData);
                if (localIndex != -1)
                {
                    CollidableObject collidable   = ObjectPool.instance.GetObjectFromPool(localIndex, objectType) as CollidableObject;
                    Quaternion       lookRotation = Quaternion.LookRotation(direction);
                    Vector3          spawnSlot    = collidable.GetSpawnSlot(platform.GetTransform().right *slotDistance, spawnData.slotPositions);
                    collidable.Orient(platform, position + (offset.z + ((i + 1) * zDelta)) * direction + spawnSlot, lookRotation);
                    if (activateImmediately)
                    {
                        collidable.Activate();
                    }

                    int objectIndex = ObjectPool.instance.GetObjectIndexFromLocalIndex(localIndex, objectType);
                    ObjectHistory.instance.ObjectSpawned(objectIndex, (offset.z + ((i + 1) * zDelta)), locationDirection,
                                                         lookRotation.eulerAngles.y, objectType);
                    platform.SpawnCollidable(i);

                    // don't allow any more of the same collidable type if we are forcing a different collidable
                    if (platform.hasDifferentCollidables)
                    {
                        break;
                    }
                }
            }
        }
        spawnData.slotPositions = 0;
    }
示例#25
0
    // Turn left or right
    public bool Turn(bool rightTurn)
    {
        // prevent two turns from occurring really close to each other (for example, to prevent a 180 degree turn)
        if (Time.time - turnTime < simultaneousTurnPreventionTime)
        {
            return(false);
        }

        RaycastHit hit;

        // ensure we are over the correct platform
        if (Physics.Raycast(thisTransform.position + colliderCenterOffset, -thisTransform.up, out hit, Mathf.Infinity, platformLayer))
        {
            PlatformObject platform    = null;
            bool           hasPlatform = (platform = hit.transform.GetComponent <PlatformObject>()) != null ||
                                         (platform = hit.transform.parent.GetComponent <PlatformObject>()) != null;
            // update the platform object
            if (hasPlatform && platform != platformObject)
            {
                platformObject = platform;
            }
        }
        bool isAboveTurn = AboveTurn();

        // if we are restricting a turn, don't turn unless we are above a turn platform
        if (restrictTurns && (!isAboveTurn || restrictTurnsToTurnTrigger))
        {
            return(false);
        }

        turnTime = Time.time;
        Vector3 direction = platformObject.GetTransform().right *(rightTurn ? 1 : -1);

        prevTurnOffset    = turnOffset;
        canUpdatePosition = ObjectGenerator.instance.UpdateSpawnDirection(direction, rightTurn, isAboveTurn, out turnOffset);
        targetRotation    = Quaternion.LookRotation(direction);
        curveOffset.x     = (thisTransform.position.x - (startPosition.x + turnOffset.x)) * Mathf.Abs(Mathf.Sin(targetRotation.eulerAngles.y * Mathf.Deg2Rad));
        curveOffset.z     = (thisTransform.position.z - (startPosition.z + turnOffset.z)) * Mathf.Abs(Mathf.Cos(targetRotation.eulerAngles.y * Mathf.Deg2Rad));
        if (isAboveTurn)
        {
            UpdateTargetPosition(targetRotation.eulerAngles.y);
        }

        return(true);
    }
    // a platform has been spawned, now spawn the scene objects and setup for a turn if needed
    private void platformSpawned(PlatformObject platform, ObjectLocation location, Vector3 direction, Vector3 distance, bool activateImmediately)
    {
        int  localIndex;
        bool isTurn = platform.isRightTurn || platform.isLeftTurn;

        if (isTurn || spawnFullLength)
        {
            // set largestScene to 0 to prevent the scene spawner from waiting for space for the largest scene object
            spawnData.largestScene   = 0;
            spawnData.useWidthBuffer = false;
        }

        // spawn all of the scene objects until we have spawned enough scene objects
        setupSection(location, true);
        while ((localIndex = infiniteObjectManager.getNextObjectIndex(ObjectType.Scene, spawnData)) != -1)
        {
            spawnSceneObject(localIndex, location, distance + localSceneDistance[(int)location] * direction + localSceneHeight[(int)location] * Vector3.up + turnOffset, direction, activateImmediately);
        }

        if (isTurn)
        {
            spawnData.largestScene   = largestSceneLength;
            spawnData.useWidthBuffer = true;

            turnPlatform[(int)location] = platform;

            if (location == ObjectLocation.Center)
            {
                setupPlatformTurn();
            }
        }
        else
        {
            localDistance[(int)location]       += platformSizes[infiniteObjectHistory.getLastLocalIndex(ObjectType.Platform)].z;
            localPlatformHeight[(int)location] += platformSizes[infiniteObjectHistory.getLastLocalIndex(ObjectType.Platform)].y;
            if (platform.sectionTransition)
            {
                infiniteObjectHistory.didSpawnSectionTranition(location, false);
            }
        }
    }
    // spawn a scene object at the specified location
    private void spawnSceneObject(int localIndex, ObjectLocation location, Vector3 position, Vector3 direction, bool activateImmediately)
    {
        SceneObject scene = (SceneObject)infiniteObjectManager.objectFromPool(localIndex, ObjectType.Scene);

        scene.orient(position + direction * sceneSizes[localIndex].z / 2, Quaternion.LookRotation(direction));

        localSceneDistance[(int)location] += sceneSizes[localIndex].z;
        int            assocaitedPlatformLocalIndex = infiniteObjectHistory.getFirstPlatformIndex();
        PlatformObject associatedPlatform           = infiniteObjectManager.localIndexToInfiniteObject(assocaitedPlatformLocalIndex, ObjectType.Platform) as PlatformObject;

        if (associatedPlatform.slope != PlatformSlope.None)
        {
            localSceneHeight[(int)location] += platformSizes[assocaitedPlatformLocalIndex].y;
        }

        int            objectIndex  = infiniteObjectManager.localIndexToObjectIndex(localIndex, ObjectType.Scene);
        InfiniteObject prevTopScene = infiniteObjectHistory.objectSpawned(objectIndex, 0, location, ObjectType.Scene, scene);

        // the current scene now becames the parent of the previous top scene
        if (prevTopScene != null)
        {
            prevTopScene.setInfiniteObjectParent(scene);
        }
        else
        {
            infiniteObjectHistory.setBottomInfiniteObject(location, true, scene);
        }

        infiniteObjectHistory.addTotalDistance(sceneSizes[localIndex].z, location, true);
        if (scene.sectionTransition)
        {
            infiniteObjectHistory.didSpawnSectionTranition(location, true);
        }

        if (activateImmediately)
        {
            scene.activate();
        }
    }
示例#28
0
    public bool aboveTurn()
    {
        RaycastHit hit;

        if (Physics.Raycast(thisTransform.position + Vector3.up / 2, -thisTransform.up, out hit, Mathf.Infinity, 1 << platformLayer))
        {
            PlatformObject platform = hit.collider.GetComponent <PlatformObject>();

            // don't allow a turn if the player is trying to do a 180 degree turn
            if (Mathf.Abs(thisTransform.eulerAngles.y - platform.getTransform().eulerAngles.y) > 0.1f)
            {
                return(false);
            }

            if (platform != null)
            {
                return(platform.isRightTurn || platform.isLeftTurn);
            }
        }

        return(true);
    }
示例#29
0
    // Spawn platforms and their attached collidables
    private PlatformObject SpawnPlatformAndCollidables(Direction locationDirection, Vector3 position,
                                                       Vector3 direction, bool activateImmediately)
    {
        SetupSection(locationDirection, false);
        spawnData.turnSpawned = turnPlatform[(int)locationDirection] != null;
        int localIndex = ObjectPool.instance.GetNextObjectIndex(ObjectType.Platform, spawnData);

        if (localIndex == -1)
        {
            return(null);
        }
        PlatformObject platform = SpawnPlatform(localIndex, locationDirection, position, direction, activateImmediately);

        if (platform.CanSpawnCollidable())
        {
            // First try to spawn an obstacle.
            // If there is any space remaining on the platform, then try to spawn a donut.
            // If there is any space remaining on the platform, then try to spawn a fuel.
            // If there is any space remaining on the platform, then try to spawn a powerup.
            SpawnCollidable(ObjectType.Obstacle, position, direction, locationDirection, platform, localIndex, activateImmediately);
            if (platform.CanSpawnCollidable())
            {
                SpawnCollidable(ObjectType.Donut, position, direction, locationDirection, platform, localIndex, activateImmediately);
                if (platform.CanSpawnCollidable())
                {
                    SpawnCollidable(ObjectType.Fuel, position, direction, locationDirection, platform, localIndex, activateImmediately);
                    if (platform.CanSpawnCollidable())
                    {
                        SpawnCollidable(ObjectType.PowerUp, position, direction, locationDirection, platform, localIndex, activateImmediately);
                    }
                }
            }
        }

        return(platform);
    }
示例#30
0
        /// <summary>
        /// (Re)Initialize les paths
        /// </summary>
        private void InitializePaths()
        {
            HeTrace.WriteLine("Paths initialization", 5);

            // Initialization according to the mode (debug/plugin)
            if (Global.DebugMode)
            {
                // Utilisation de pseudos dossiers
                _PlatformFolders = ((MvPlatform)PlatformObject).GetAllPlatformFolders();
            }
            else
            {
                // Récupération de tous les dossiers + tri
                _PlatformFolders = PlatformObject.GetAllPlatformFolders()
                                   .OrderBy(x => x.MediaType).ToArray();
            }

            //
            HeTrace.WriteLine($"Dossier de jeu: {PlatformObject.Folder}");
            C_Platform tmp = C_Platform.Platform_Maker(PlatformObject, _PlatformFolders);

            PlatformPaths = tmp;
            GC.Collect();
        }
示例#31
0
 private void ActivateMap(PlatformObject map, Vector3 position)
 {
     map.Instance.transform.position = position;
     map.Instance.SetActive(true);
     map.Visible = true;
 }
示例#32
0
 public void Start()
 {
     platform = transform.parent.GetComponent<PlatformObject>();
 }
示例#33
0
 public static void GetDefaultLinuxPlatform(ref PlatformObject obj, string unitTestContent)
 {
     obj.ClassName = "Linux.Default";
     obj.PlatformSubType = "Generic";
     obj.Edition = "";
     obj.Version = "";
 }
示例#34
0
    // a platform has been spawned, now spawn the scene objects and setup for a turn if needed
    private void platformSpawned(PlatformObject platform, ObjectLocation location, Vector3 direction, bool activateImmediately)
    {
        int localIndex;
        bool isTurn = platform.leftTurn || platform.rightTurn;
        if (isTurn || spawnFullLength) {
            // set largestScene to 0 to prevent the scene spawner from waiting for space for the largest scene object
            spawnData.largestScene = 0;
            spawnData.useWidthBuffer = false;
        }

        // spawn all of the scene objects until we have spawned enough scene objects
        setupSection(location, true);
        while ((localIndex = infiniteObjectManager.getNextObjectIndex(ObjectType.Scene, spawnData)) != -1) {
            Vector3 position = Vector3.zero;
            SceneObject prevScene = infiniteObjectHistory.getTopInfiniteObject(location, true) as SceneObject;
            bool useZSize = true;
            // may be null if coming from a turn
            if (prevScene == null) {
                prevScene = infiniteObjectHistory.getTopInfiniteObject(ObjectLocation.Center, true) as SceneObject;
                useZSize = false;
            }
            if (prevScene) {
                int prevSceneIndex = infiniteObjectHistory.getLastLocalIndex(location, ObjectType.Scene);
                position = prevScene.getTransform().position - sceneStartPosition[prevSceneIndex] + (useZSize ? sceneSizes[prevSceneIndex].z : sceneSizes[prevSceneIndex].x) / 2 * direction + sceneSizes[prevSceneIndex].y * Vector3.up;
            }
            spawnSceneObject(localIndex, location, position, direction, activateImmediately);
            // the section may change because of the newly spawned scene object
            setupSection(location, true);
        }

        if (isTurn) {
            spawnData.largestScene = largestSceneLength;
            spawnData.useWidthBuffer = true;

            turnPlatform[(int)location] = platform;

            if (location == ObjectLocation.Center) {
                infiniteObjectHistory.resetTurnCount();
            }
        } else if (platform.sectionTransition) {
            infiniteObjectHistory.didSpawnSectionTranition(location, false);
        }
    }
示例#35
0
	public override void init()
	{
        base.init();

		platformObject = GetComponent<PlatformObject>();
	}
示例#36
0
        public static void GetGentooPlatform(ref PlatformObject obj, string unitTestContent)
        {
            //Version list available at http://gentest.neysx.org/proj/en/releng/#doc_chap6
            //Versioning is primarily based on date.
            //Unique version variations for parsing include:
            //		Gentoo Base System release 1.12.11.1

            List<string> lines;
            if (unitTestContent != null)
                lines = ParseString(unitTestContent);
            else
                lines = ParseFile("/etc/" + obj.VersionFile);

            obj.ClassName = "Linux.Gentoo";
            obj.PlatformSubType = "Gentoo";
            obj.Edition = "";
            int pt = lines[0].LastIndexOf(" ");
            obj.Version = lines[0].Substring(pt+1,lines[0].Length - pt +1);
        }
示例#37
0
        // move all of the active objects
        public void MoveObjects(float moveDistance)
        {
            if (moveDistance == 0)
            {
                return;
            }

            // the distance to move the objects
            Vector3 delta = moveDirection * moveDistance;

            if (moveDirection != spawnDirection)
            {
                wrongMoveDistance += moveDistance;
            }

            // only move the top most platform/scene of each ObjectLocation because all of the other objects are children of these two
            // objects. Only have to check the bottom-most platform/scene as well to determine if it should be removed
            InfiniteObject infiniteObject  = null;
            Transform      objectTransform = null;
            PlatformObject platformObject  = null;

            for (int i = 0; i < 2; ++i)   // loop through the platform and scenes
            {
                for (int j = 0; j < (int)ObjectLocation.Last; ++j)
                {
                    // move
                    infiniteObject = infiniteObjectHistory.GetTopInfiniteObject((ObjectLocation)j, i == 0);
                    if (infiniteObject != null)
                    {
                        objectTransform = infiniteObject.GetTransform();
                        Vector3 pos = objectTransform.position;
                        pos -= delta;
                        objectTransform.position = pos;

                        // check for removal.. there will always be a bottom object if there is a top object
                        infiniteObject = infiniteObjectHistory.GetBottomInfiniteObject((ObjectLocation)j, i == 0);
                        if (playerTransform.InverseTransformPoint(infiniteObject.GetTransform().position).z < removeHorizon)
                        {
                            // if the infinite object is a platform and it has changes height, move everything down by that height
                            if (heightReposition && i == 1)   // 1 are platforms
                            {
                                platformObject = infiniteObject as PlatformObject;
                                if (platformObject.slope != PlatformSlope.None)
                                {
                                    TransitionHeight(platformSizes[platformObject.GetLocalIndex()].y);
                                }
                            }

                            if (turnPlatform[j] == infiniteObject)
                            {
                                turnPlatform[j] = null;
                            }
                            infiniteObjectHistory.ObjectRemoved((ObjectLocation)j, i == 0);
                            infiniteObject.Deactivate();
                        }
                    }
                }

                // loop through all of the turn objects
                infiniteObject = infiniteObjectHistory.GetTopTurnInfiniteObject(i == 0);
                if (infiniteObject != null)
                {
                    objectTransform = infiniteObject.GetTransform();
                    Vector3 pos = objectTransform.position;
                    pos -= delta;
                    objectTransform.position = pos;

                    infiniteObject = infiniteObjectHistory.GetBottomTurnInfiniteObject(i == 0);
                    if (playerTransform.InverseTransformPoint(infiniteObject.GetTransform().position).z < removeHorizon)
                    {
                        infiniteObjectHistory.TurnObjectRemoved(i == 0);
                        infiniteObject.Deactivate();
                    }
                }
            }

            if (!stopObjectSpawns)
            {
                dataManager.AddToScore(moveDistance);
                SpawnObjectRun(true);
            }
        }
示例#38
0
    public override void orient(PlatformObject parent, Vector3 position, Quaternion rotation)
	{
        base.orient(parent, position, rotation);
		
		platformParent = parent;
		platformParent.onPlatformDeactivation += collidableDeactivation;
	}
示例#39
0
        public override CollideTypeConstants Collide(BCBlockGameState gstate, PlatformObject otherobject)
        {
            bool currreturn = false;
            foreach (GameCharacterAbility gca in _Abilities)
            {
                currreturn = gca.Collide(gstate,this, otherobject);

            }

            if (!currreturn) return base.Collide(gstate,otherobject);
            else return CollideTypeConstants.Collide_Nothing;
        }
示例#40
0
    // Turn left or right
    public bool turn(bool rightTurn, bool fromInputManager)
    {
        // prevent two turns from occurring really close to each other (for example, to prevent a 180 degree turn)
        if (Time.time - turnTime < simultaneousTurnPreventionTime) {
            return false;
        }

        RaycastHit hit;
        // ensure we are over the correct platform
        if (Physics.Raycast(thisTransform.position + capsuleCollider.center, -thisTransform.up, out hit, Mathf.Infinity, platformLayer)) {
            PlatformObject platform = null;
            // update the platform object
            if (((platform = hit.transform.GetComponent<PlatformObject>()) != null) || ((platform = hit.transform.parent.GetComponent<PlatformObject>()) != null)) {
                if (platform != platformObject) {
                    platformObject = platform;
                    checkForCurvedPlatform();
                }
            }
        }
        bool isAboveTurn = abovePlatform(true);

        // if we are restricting a turn, don't turn unless we are above a turn platform
        if (restrictTurns && (!isAboveTurn || restrictTurnsToTurnTrigger)) {
            if (fromInputManager) {
                turnRequestTime = Time.time;
                turnRightRequest = rightTurn;
                return false;
            }

            if (!powerUpManager.isPowerUpActive(PowerUpTypes.Invincibility) && !powerUpManager.isPowerUpActive(PowerUpTypes.SpeedIncrease) && !autoTurn) {
                // turn in the direction that the player swiped
                rightTurn = turnRightRequest;

                // don't turn if restrict turns is on and the player hasn't swipped within the grace period time or if the player isn't above a turn platform
                if (!gameManager.godMode && (Time.time - turnRequestTime > turnGracePeriod || !isAboveTurn)) {
                    return false;
                }
            }
        } else if (!fromInputManager && !autoTurn && !gameManager.godMode && (!restrictTurns || Time.time - turnRequestTime > turnGracePeriod) &&
                    !powerUpManager.isPowerUpActive(PowerUpTypes.Invincibility) && !powerUpManager.isPowerUpActive(PowerUpTypes.SpeedIncrease)) {
            return false;
        }

        turnTime = Time.time;
        Vector3 direction = platformObject.getTransform().right * (rightTurn ? 1 : -1);
        turnOffset = infiniteObjectGenerator.updateSpawnDirection(direction, platformObject.curveLength == 0, rightTurn, isAboveTurn);
        if (platformObject.curveLength > 0) {
            followCurve = true;
        } else {
            targetRotation = Quaternion.LookRotation(direction);
            curveOffset.x = (thisTransform.position.x - (startPosition.x + turnOffset.x)) * Mathf.Abs(Mathf.Sin(targetRotation.eulerAngles.y * Mathf.Deg2Rad));
            curveOffset.z = (thisTransform.position.z - (startPosition.z + turnOffset.z)) * Mathf.Abs(Mathf.Cos(targetRotation.eulerAngles.y * Mathf.Deg2Rad));
            if (isAboveTurn) {
                updateTargetPosition(targetRotation.eulerAngles.y);
            }
        }
        return true;
    }
示例#41
0
    // There character doesn't move, all of the objects around it do. Make sure the character is in the correct position
    public void Update()
    {
        Vector3 moveDirection = Vector3.zero;
        float hitDistance = 0;
        RaycastHit hit;
        // cast a ray to see if we are over any platforms
        if (Physics.Raycast(thisTransform.position + capsuleCollider.center, -thisTransform.up, out hit, Mathf.Infinity, platformLayer)) {
            hitDistance = hit.distance;
            PlatformObject platform = null;
            // compare the has code to prevent having to look up GetComponent every frame
            if (prevHitHashCode != hit.GetHashCode()) {
                prevHitHashCode = hit.GetHashCode();
                // update the platform object
                if (((platform = hit.transform.GetComponent<PlatformObject>()) != null) || ((platform = hit.transform.parent.GetComponent<PlatformObject>()) != null)) {
                    if (platform != platformObject) {
                        platformObject = platform;
                        checkForCurvedPlatform();
                    }
                }
            }

            // we are over a platform, determine if we are on the ground of that platform
            if (hit.distance <= capsuleCollider.height / 2 + 0.0001f) {
                onGround = true;
                // we are on the ground. Get the platform object and check to see if we are on a curve
                // if we are sliding and the platform has a slope then stop sliding
                if (isSliding) {
                    if (platformObject != null && platformObject.slope != PlatformSlope.None) {
                        StopCoroutine("doSlide");
                        stopSlide(true);
                    }
                }

                // if we are jumping we either want to start jumping or land
                if (isJumping) {
                    if (isJumpPending) {
                        moveDirection.y += jumpSpeed;
                        cameraController.adjustVerticalOffset(jumpSpeed * Time.deltaTime);
                        jumpSpeed += gravity * Time.deltaTime;
                        onGround = false;
                    } else {
                        isJumping = false;
                        jumpLandTime = Time.time;
                        if (enabled)
                            playerAnimation.run();
                        groundCollisionParticleSystem.Play();
                    }
                } else {
                    // we are not jumping so our position should be the same as the hit point
                    Vector3 position = thisTransform.position;
                    position.y = hit.point.y;
                    thisTransform.position = position;
                }
                skipFrame = true;
                // a hit distance of -1 means that the platform is within distance
                hitDistance = -1;
            }
            // if we didn't hit a platform we may hit a floor
        } else if (Physics.Raycast(thisTransform.position + capsuleCollider.center, -thisTransform.up, out hit, Mathf.Infinity, floorLayer)) {
            hitDistance = hit.distance;
        }

        if (hitDistance != -1) {
            // a platform is beneith us but it is far away. If we are jumping apply the jump speed and gravity
            if (isJumping) {
                moveDirection.y += jumpSpeed;
                cameraController.adjustVerticalOffset(jumpSpeed * Time.deltaTime);
                jumpSpeed += gravity * Time.deltaTime;

                // the jump is no longer pending if we are in the air
                if (isJumpPending) {
                    isJumpPending = false;
                }
            } else if (!skipFrame) {
                // apply gravity if we are not jumping
                moveDirection.y = gravity * (powerUpManager.isPowerUpActive(PowerUpTypes.SpeedIncrease) ? 2 : 1); // the speed power up needs a little extra push
            }

            if (!skipFrame && hitDistance == 0) {
                platformObject = null;
            }
            if (skipFrame) {
                skipFrame = false;
            } else if (hitDistance != 0 && thisTransform.position.y + (moveDirection.y * Time.deltaTime) < hit.point.y) {
                // this transition should be instant so ignore Time.deltaTime
                moveDirection.y = (hit.point.y - thisTransform.position.y) / Time.deltaTime;
            }
            onGround = false;
        }

        float xStrafe = (targetPosition.x - thisTransform.position.x) * Mathf.Abs(Mathf.Cos(targetRotation.eulerAngles.y * Mathf.Deg2Rad)) / Time.deltaTime;
        float zStrafe = (targetPosition.z - thisTransform.position.z) * Mathf.Abs(Mathf.Sin(targetRotation.eulerAngles.y * Mathf.Deg2Rad)) / Time.deltaTime;
        moveDirection.x += Mathf.Clamp(xStrafe, -horizontalSpeed, horizontalSpeed);
        moveDirection.z += Mathf.Clamp(zStrafe, -horizontalSpeed, horizontalSpeed);
        thisTransform.position += moveDirection * Time.deltaTime;

        // Make sure we don't run into a wall
        if (Physics.Raycast(thisTransform.position + Vector3.up, thisTransform.forward, capsuleCollider.radius, 1 << wallLayer)) {
            gameManager.gameOver(GameOverType.Wall, true);
        }

        if (!gameManager.isGameActive()) {
            enabled = inAir(); // keep the character active for as long as they are in the air so gravity can keep pushing them down.
        }
    }
示例#42
0
    public void reset()
    {
        thisTransform.position = startPosition;
        thisTransform.rotation = startRotation;

        slideData.duration = 0;
        stumbleData.duration = 0;

        jumpSpeed = 0;
        isJumping = false;
        isJumpPending = false;
        isSliding = false;
        isStumbling = false;
        onGround = true;
        prevHitHashCode = -1;
        currentSlotPosition = SlotPosition.Center;
        targetSlotValue = (int)currentSlotPosition * infiniteObjectGenerator.slotDistance;
        playerAnimation.reset();
        if (projectileManager)
            projectileManager.reset();
        pauseCollisionParticlePlaying = false;
        totalMoveDistance = 0;
        turnOffset = Vector3.zero;
        curveOffset = Vector3.zero;
        turnTime = Time.time;
        jumpLandTime = Time.time;
        forwardSpeeds.reset();

        platformObject = null;
        curveTime = -1;
        curveMoveDistance = 0;
        curveDistanceMapIndex = 0;
        followCurve = false;

        targetRotation = startRotation;
        updateTargetPosition(targetRotation.eulerAngles.y);
    }
示例#43
0
 /// <summary>
 /// called when gamecharacter collides with a platformobject.
 /// </summary>
 /// <param name="gstate"></param>
 /// <param name="gamechar"></param>
 /// <param name="otherobject"></param>
 /// <returns>false to continue default processing. true to return immediately without default processing.</returns>
 public abstract bool Collide(BCBlockGameState gstate, GameCharacter gamechar, PlatformObject otherobject);
示例#44
0
        public static void GetRedHatPlatform(ref PlatformObject obj, string unitTestContent)
        {
            //Version list is available at ...
            //Unique version variations for parsing include:
            //		Red Hat Enterprise Linux Server release 5 (Tikanga)
            //		Red Hat Enterprise Linux AS release 4 (Nahant Update 3)
            //		Red Hat Advanced Server Linux AS release 2.1 (Pensacola)
            //		Red Hat Enterprise Linux ES release 3 (Taroon Update 4)

            List<string> lines;
            if (unitTestContent != null)
                lines = ParseString(unitTestContent);
            else
                lines = ParseFile("/etc/" + obj.VersionFile);

            int pt = lines[0].IndexOf("release");
            int pt2 = lines[0].IndexOf("(");
            int pt3 = lines[0].IndexOf(")");
            int pt4 = lines[0].IndexOf("Linux");

            obj.ClassName = "Linux.RedHat";
            obj.PlatformSubType = lines[0].Substring(0, pt4-1);
            obj.Edition = lines[0].Substring(pt2+1, pt3-1-pt2);
            obj.Version = lines[0].Substring(pt+8, pt2 - 1 - pt + 8).Trim();
        }
示例#45
0
 public static void GetArchPlatform(ref PlatformObject obj, string unitTestContent)
 {
     // Arch is not versioned. It is a single rolling version.
     // The existance of the arch-release file determines arch
     // is being used. The actual file is blank.
     obj.ClassName = "Linux.Arch";
     obj.PlatformSubType = "Arch";
     obj.Edition = "";
     obj.Version = "Current";
 }
示例#46
0
        public static void GetMandrivaPlatform(ref PlatformObject obj, string unitTestContent)
        {
            //Formerly known as Mandrake Linux
            //Version list is available at http://en.wikipedia.org/wiki/Mandriva_Linux
            //Unique version variations for parsing include:
            //		Mandriva Linux release 2010.0 (Official) for i586

            List<string> lines;
            if (unitTestContent != null)
                lines = ParseString(unitTestContent);
            else
                lines = ParseFile("/etc/" + obj.VersionFile);

            obj.ClassName = "Linux.Mandriva";
            obj.PlatformSubType = "Mandriva";
            obj.Edition = "";
            int pt = lines[0].IndexOf("release");
            int pt2 = lines[0].IndexOf("(");
            obj.Version = lines[0].Substring(pt+8, pt2-1).Trim();

            switch (obj.Version)
            {
                case "2010.0":
                    obj.Edition = "Mandriva Linux 2010";
                    break;
                case "2009.1":
                    obj.Edition = "Mandriva Linux 2009 Spring";
                    break;
                case "2009.0":
                    obj.Edition = "Mandriva Linux 2009";
                    break;
                case "2008.1":
                    obj.Edition = "Mandriva Linux 2008 Spring";
                    break;
                case "2008.0":
                    obj.Edition = "Mandriva Linux 2008";
                    break;
                case "2007.1":
                    obj.Edition = "Mandriva Linux 2007 Spring";
                    break;
                case "2007":
                    obj.Edition = "Mandriva Linux 2007";
                    break;
                case "2006.0":
                    obj.Edition = "Mandriva Linux 2006";
                    break;
                case "10.2":
                    obj.Edition = "Limited Edition 2005";
                    break;
                case "10.1":
                    obj.Edition = "Community and Official";
                    break;
                case "10.0":
                    obj.Edition = "Community and Official";
                    break;
                case "9.2":
                    obj.Edition = "FiveStar";
                    break;
                case "9.1":
                    obj.Edition = "Bamboo";
                    break;
                case "9.0":
                    obj.Edition = "Dolphin";
                    break;
                case "8.2":
                    obj.Edition = "Bluebird";
                    break;
                case "8.1":
                    obj.Edition = "Vitamin";
                    break;
                case "8.0":
                    obj.Edition = "Traktopel";
                    break;
                case "7.2":
                    obj.Edition = "Odyssey";
                    break;
                case "7.1":
                    obj.Edition = "Helium";
                    break;
                case "7.0":
                    obj.Edition = "Air";
                    break;
                case "6.1":
                    obj.Edition = "Helios";
                    break;
                case "6.0":
                    obj.Edition = "Venus";
                    break;
                case "5.3":
                    obj.Edition = "Festen";
                    break;
                case "5.2":
                    obj.Edition = "Leeloo";
                    break;
                case "5.1":
                    obj.Edition = "Venice";
                    break;
                default:
                    obj.Edition = "Unknown";
                    break;
            }
        }
示例#47
0
        public static PlatformObject Load()
        {
            System.IO.DirectoryInfo di = new System.IO.DirectoryInfo("/etc");
            System.IO.FileInfo[] release = di.GetFiles("*-release");
            System.IO.FileInfo[] debian = di.GetFiles("debian_version");
            System.IO.FileInfo[] slackware = di.GetFiles("slackware-version");

            PlatformObject obj = new PlatformObject();
            obj.ClassName = null;
            obj.PlatformType = "Linux";
            obj.PlatformSubType = "";
            obj.Edition = "";
            obj.Version = "";
            obj.VersionFile  = "";

            if (release.Length > 0)
            {
                string str = release[0].ToString();
                string platformType = str.Substring(5,str.Length-13);
                obj.VersionFile = "/etc/" + str;

                switch (platformType)
                {
                    case "arch":
                        GetArchPlatform(ref obj, null);
                        break;
                    case "fedora":
                        GetFedoraPlatform(ref obj, null);
                        break;
                    case "gentoo":
                        GetGentooPlatform(ref obj, null);
                        break;
                    case "mandriva":
                        GetMandrivaPlatform(ref obj, null);
                        break;
                    case "redhat": 	//RedHat variants
                        GetRedHatPlatform(ref obj, null);
                        break;
                    case "suse":
                        GetSusePlatform(ref obj, null);
                        break;
                    case "lsb": 	//Ubuntu variants
                        GetUbuntuPlatform(ref obj, null);
                        break;
                    default:
                        GetDefaultLinuxPlatform(ref obj, null);
                        break;
                }
            }
            else if (slackware.Length > 0)
            {
                obj.VersionFile = "/etc/" + slackware[0].ToString();
                GetSlackwarePlatform(ref obj, null);
            }
            else if (debian.Length > 0)
            {
                obj.VersionFile = "/etc/" + debian[0].ToString();
                GetDebianPlatform(ref obj, null);
            }
            else
            {
                GetDefaultLinuxPlatform(ref obj, null);
            }

            if (obj.ClassName == null)
                throw new ArgumentNullException("ClassName was not defined. Please report this bug.");

            //Add project namespace
            obj.ClassName = "GitSharp.Platform."+obj.ClassName;

            return obj;
        }
示例#48
0
        public static void GetFedoraPlatform(ref PlatformObject obj, string unitTestContent)
        {
            //Version list available at http://fedoraproject.org/wiki/Releases
            //Unique version variations for parsing include:
            //		Fedora release 8 (Werewolf)
            //		Fedora Core release 6 (Zod)

            List<string> lines;
            if (unitTestContent != null)
                lines = ParseString(unitTestContent);
            else
                lines = ParseFile("/etc/" + obj.VersionFile);

            int pt = lines[0].IndexOf("release");
            int pt2 = lines[0].IndexOf("(");
            int pt3 = lines[0].IndexOf(")");

            obj.ClassName = "Linux.Fedora";
            obj.PlatformSubType = lines[0].Substring(0,pt-1).Trim();
            obj.Version = lines[0].Substring(pt+8, pt2-1).Trim();
            obj.Edition = lines[0].Substring(pt2+1,pt3-1).Trim();
        }
示例#49
0
        public static void GetUbuntuPlatform(ref PlatformObject obj, string unitTestContent)
        {
            //Version list is available at http://en.wikipedia.org/wiki/Ubuntu_(Linux_distribution)
            //Unique version variations for parsing include (multi-line):
            //		DISTRIB_ID=Ubuntu
            //		DISTRIB_RELEASE = 9.04
            //		DISTRIB_CODENAME=jaunty
            //		DISTRIB_DESCRIPTION = Ubuntu 9.04
            //Because Ubuntu can identify variants, we'll use the DISTRIB_ID
            //to identify the variant (such as KUbuntu, XUbuntu) instead of
            //a static string setting.

            List<string> lines;
            if (unitTestContent == null)
                lines = ParseFile("/etc/" + obj.VersionFile);
            else
                lines = ParseString(unitTestContent);

            obj.ClassName = "Linux.Ubuntu";
            int pt = lines[0].IndexOf("=");
            obj.PlatformSubType = lines[0].Substring(pt+1).Trim();
            int pt1 = lines[2].IndexOf("=");
            obj.Edition = lines[2].Substring(pt1+1).Trim();
            int pt2 = lines[1].IndexOf("=");
            obj.Version = lines[1].Substring(pt2+1).Trim();
        }
示例#50
0
 // orient for collidables which have a platform as a parent
 public virtual void orient(PlatformObject parent, Vector3 position, Quaternion rotation)
 {
     thisTransform.parent = parent.getTransform();
     Vector3 pos = Vector3.zero;
     float yAngle = rotation.eulerAngles.y;
     pos.Set(startPosition.x * Mathf.Cos(yAngle * Mathf.Deg2Rad) + startPosition.z * Mathf.Sin(yAngle * Mathf.Deg2Rad), startPosition.y,
             -startPosition.x * Mathf.Sin(yAngle * Mathf.Deg2Rad) + startPosition.z * Mathf.Cos(yAngle * Mathf.Deg2Rad));
     pos += position;
     thisTransform.localPosition = parent.getTransform().InverseTransformPoint(pos);
     thisTransform.rotation = startRotation;
     thisTransform.Rotate(0, rotation.eulerAngles.y, 0, Space.World);
 }
示例#51
0
 public static void GetUbuntuPlatform(ref PlatformObject obj)
 {
     GetUbuntuPlatform(ref obj, null);
 }
示例#52
0
    // returns true if there is still space on the platform for a collidable object to spawn
    private void spawnCollidable(ObjectType objectType, Vector3 position, Vector3 direction, ObjectLocation location, PlatformObject platform, int platformLocalIndex, bool activateImmediately)
    {
        int collidablePositions = platform.collidablePositions;
        // can't do anything if the platform doesn't accept any collidable object spawns
        if (collidablePositions == 0)
            return;

        Vector3 offset = platformSizes[platformLocalIndex] * 0.1f;
        float zDelta = platformSizes[platformLocalIndex].z * .8f / (1 + collidablePositions);

        for (int i = 0; i < collidablePositions; ++i) {
            if (platform.canSpawnCollidable(i)) {
                spawnData.slotPositions = platform.getSlotsAvailable();
                int localIndex = infiniteObjectManager.getNextObjectIndex(objectType, spawnData);
                if (localIndex != -1) {
                    CollidableObject collidable = infiniteObjectManager.objectFromPool(localIndex, objectType) as CollidableObject;
                    Quaternion lookRotation = Quaternion.LookRotation(direction);
                    Vector3 spawnSlot = collidable.getSpawnSlot(platform.getTransform().right * slotDistance, spawnData.slotPositions);
                    collidable.orient(platform, position + (offset.z + ((i + 1) * zDelta)) * direction + spawnSlot, lookRotation);
                    if (activateImmediately)
                        collidable.activate();
                    
                    int objectIndex = infiniteObjectManager.localIndexToObjectIndex(localIndex, objectType);
                    infiniteObjectHistory.objectSpawned(objectIndex, (offset.z + ((i + 1) * zDelta)), location, lookRotation.eulerAngles.y, objectType);
                    platform.collidableSpawned(i);

                    // don't allow any more of the same collidable type if we are forcing a different collidable
                    if (platform.forceDifferentCollidableTypes)
                        break;
                }
            }
        }
        spawnData.slotPositions = 0;
    }
示例#53
0
        public static void GetSusePlatform(ref PlatformObject obj, string unitTestContent)
        {
            //Version list is available at http://en.wikipedia.org/wiki/SUSE_Linux
            //Unique version variations for parsing include (multi-line):
            //		SUSE LINUX 10.0 (X86-64) OSS
            //		VERSION = 10.0

            List<string> lines;
            if (unitTestContent != null)
                lines = ParseString(unitTestContent);
            else
                lines = ParseFile("/etc/" + obj.VersionFile);

            int pt = lines[1].IndexOf(" ");
            obj.Version = lines[0].Substring(pt+1, lines[0].Length - 1);
            obj.ClassName = "Linux.Suse";
            obj.PlatformSubType = "Suse";
            obj.Edition = "";
            obj.Version = lines[1].Substring(11, lines[1].Length - 11);
        }
示例#54
0
 public static void GetDebianPlatform(ref PlatformObject obj, string unitTestContent)
 {
     //Version list available at: http://www.debian.org/releases/
     //There is no accurate way to determine the version information
     //in Debian. The community mixes the versions regularly and
     //argues that programs should not rely on this information,
     //instead using the dependencies to determine if a program will
     //work. Unfortunately, this viewpoint does little for generic
     //informational purposes, version based bug reporting, etc. They
     //have not standardized this process, even for the
     //lsb_release package. The information provided in
     // /etc/debian_version is often incorrect and should not be used.
     obj.ClassName = "Linux.Debian";
     obj.PlatformSubType = "Debian";
     obj.Edition = "";
     obj.Version = "";
 }
示例#55
0
 public static void GetSusePlatform(ref PlatformObject obj)
 {
     GetSusePlatform(ref obj, null);
 }
示例#56
0
文件: Mac.cs 项目: stschake/GitSharp
        public static PlatformObject Load()
        {
            //Version list available at http://fedoraproject.org/wiki/Releases
            //Unique version variations for parsing include:
            //		Darwin 9.8.0 Power Macintosh

            ProcessStartInfo info = new ProcessStartInfo();
            info.FileName = "uname";
            info.Arguments = "-mrs";
            info.UseShellExecute = false;
            info.RedirectStandardOutput = true;

            using (Process process = Process.Start(info))
            {
                using (StreamReader reader = process.StandardOutput)
                {
                    string result = reader.ReadToEnd();

                    int pt = result.IndexOf(" ");
                    int pt2 = result.IndexOf(" ",pt+1);
                    int pt3 = pt2+1;

                    PlatformObject obj = new PlatformObject();
                    obj.ClassName = "Macintosh.Macosx";
                    obj.PlatformSubType = "";
                    obj.Version = result.Substring(pt2, pt3).Trim();
                    obj.Edition = result.Substring(0,pt).Trim();

                    //Add project namespace
                    obj.ClassName = "GitSharp.Platform."+obj.ClassName;

                    return obj;
                }
            }
        }
示例#57
0
        public static void GetSlackwarePlatform(ref PlatformObject obj, string unitTestContent)
        {
            //Version list is available at ...
            //Unique version variations for parsing include:
            //		Slackware 13.0.0.0.0

            List<string> lines;
            if (unitTestContent != null)
                lines = ParseString(unitTestContent);
            else
                lines = ParseFile("/etc/" + obj.VersionFile);

            obj.ClassName = "Linux.Slackware";
            obj.PlatformSubType = "Slackware";
            obj.Edition = "";
            int pt = lines[0].IndexOf(" ");
            obj.Version = lines[0].Substring(pt+1, lines[0].Length - 1);
        }
示例#58
0
        /// <summary>
        /// called when gamecharacter collides with a platformobject.
        /// </summary>
        /// <param name="gstate"></param>
        /// <param name="gamechar"></param>
        /// <param name="otherobject"></param>
        /// <returns>false to continue default processing. true to return immediately without default processing.</returns>
        public override bool Collide(BCBlockGameState gstate, GameCharacter gamechar, PlatformObject otherobject)
        {
            //kill the other object, and leave us unaffected.
            //but- only for types deriving from PlatformEnemy

            if(otherobject is PlatformEnemy)
            {
                otherobject.Kill();

            return true;
              }
                return false; //default processing...
        }
示例#59
0
 public override CollideTypeConstants Collide(BCBlockGameState gstate, PlatformObject otherobject)
 {
     return CollideTypeConstants.Collide_Nothing; //nuffin happens.
 }