Beispiel #1
0
    void Start()
    {
        speedyUnlocker = GameObject.Instantiate(SpeedrunUnlockerPrefab).GetComponent <AchievementUnlocker>();

        superSpeedyUnlocker = GameObject.Instantiate(Speedrun2UnlockerPrefab).GetComponent <AchievementUnlocker>();

        noDeathUnlocker = GameObject.Instantiate(NoDeathUnlockerPrefab).GetComponent <AchievementUnlocker>();

        var minutes = SaveManager.save.playTime / 60;

        if (minutes <= 20)
        {
            speedyUnlocker.UnlockAchievement();
        }
        else if (minutes <= 10)
        {
            superSpeedyUnlocker.UnlockAchievement();
        }
        if (SaveManager.save.droneCount == 0)
        {
            noDeathUnlocker.UnlockAchievement();
        }
        Debug.Log("Beat game in " + minutes + " minutes");
        Debug.Log("Used " + SaveManager.save.droneCount + " drones");
    }
Beispiel #2
0
    public void BuyClicked()
    {
        if (SaveManager.save == null)
        {
            return;
        }

        if (SaveManager.save.picolinium < price || SaveManager.save.unlocks.Contains(gameObject.name))
        {
            return;
        }

        SaveManager.save.picolinium -= price;
        SaveManager.save.unlocks.Add(gameObject.name);
        SaveManager.save.Write();

        foreach (Unlockable unlockable in FindObjectsOfType <Unlockable>())
        {
            unlockable.UpdateState();
        }

        if (unlockUnlocker == null)
        {
            unlockUnlocker = AchievementUnlocker.MakeUnlocker("allunlocks");
            if (SaveManager.save.unlocks.Count == 13)
            {
                unlockUnlocker.UnlockAchievement();
            }
        }
    }
    // INTERNALS

    private void Initialize(string i_DatabaseResourcePath)
    {
        m_Database = Resources.Load <AchievementsUnlockersDatabase>(i_DatabaseResourcePath);

        if (m_Database != null)
        {
            for (int achievementConditionDescriptorIndex = 0; achievementConditionDescriptorIndex < m_Database.elementsCount; ++achievementConditionDescriptorIndex)
            {
                AchievementUnlockerDescriptor achievementUnlockerDescriptor = m_Database.GetAchievementConditionDescriptor(achievementConditionDescriptorIndex);
                if (achievementUnlockerDescriptor != null)
                {
                    string achievementId = achievementUnlockerDescriptor.achievementId;
                    if (achievementId != "")
                    {
                        AchievementUnlocker achievementUnlocker = new AchievementUnlocker(achievementUnlockerDescriptor);
                        m_AchievementsUnlockers.Add(achievementUnlocker);
                    }
                }
            }
        }
        else
        {
            LogManager.LogWarning(this, "Database could not be loaded.");
        }
    }
 private void OnCollisionEnter(Collision collision)
 {
     if (!triedUnlock && collision.gameObject.name == "Player" && !AchievementRockChecker.HasTouchedRock())
     {
         AchievementUnlocker.MakeUnlocker("world4_3").UnlockAchievement();
         triedUnlock = true;
     }
 }
Beispiel #5
0
 private void OnCollisionEnter(Collision collision)
 {
     if (!triedUnlock && collision.gameObject.name == "Player" && AchievementGrateChecker.GetCount() == 0)
     {
         AchievementUnlocker.MakeUnlocker("world5_3").UnlockAchievement();
         triedUnlock = true;
     }
 }
Beispiel #6
0
 private void Awake()
 {
     Unlocker = GameObject.Find("AchievementUnlocker").GetComponent <AchievementUnlocker>();
     if (Unlocker != null)
     {
         Debug.Log("Loaded achievement unlocker");
     }
 }
 private void UpdateUnlockers()
 {
     for (int index = 0; index < m_AchievementsUnlockers.Count; ++index)
     {
         AchievementUnlocker achievementUnlocker = m_AchievementsUnlockers[index];
         if (achievementUnlocker != null)
         {
             achievementUnlocker.Update();
         }
     }
 }
    public static AchievementUnlocker MakeUnlocker(string AchievementIDStr)
    {
        var gameobj = Resources.Load <GameObject>("AchievementUnlocker");

        if (gameobj == null)
        {
            Debug.LogError("Error -- could not fabricate AchievementUnlocker");
        }
        AchievementUnlocker result = gameobj.GetComponent <AchievementUnlocker>();

        result.AchievementIDStr = AchievementIDStr;
        return(result);
    }
Beispiel #9
0
    void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.name != "Player")
        {
            return;
        }

        if (!triedUnlock && AchievementDashChecker.GetCount() == 0)
        {
            AchievementUnlocker.MakeUnlocker("world3_2").UnlockAchievement();
            triedUnlock = true;
        }
    }
Beispiel #10
0
    private void CheckRegrapple(GameObject collided)
    {
        if (collided == null)
        {
            return;
        }

        if (regrappleUnlocker == null)
        {
            regrappleUnlocker = AchievementUnlocker.MakeUnlocker("doublegrapple");
        }

        int grappled = collided.GetInstanceID();

        if (lastGrappled == grappled)
        {
            regrappleUnlocker.UnlockAchievement();
        }

        lastGrappled = grappled;
    }
 void IncrementCrashCount(bool write)
 {
     if (SaveManager.save != null)
     {
         SaveManager.save.crashCount += 1;
         if (write)
         {
             SaveManager.Write();
         }
         if (SaveManager.save.crashCount >= 3)
         {
             if (crashUnlocker == null)
             {
                 crashUnlocker = Resources.Load <GameObject>("AchievementUnlocker").GetComponent <AchievementUnlocker>();
                 if (crashUnlocker != null)
                 {
                     crashUnlocker.AchievementIDStr = "dronecrash";
                     crashUnlocker.UnlockAchievement();
                 }
             }
         }
     }
 }
Beispiel #12
0
    public void EquipClicked()
    {
        if (SaveManager.save == null)
        {
            return;
        }

        if (UnlockType == Type.Upgrade)
        {
            SaveManager.save.currentUpgrade = gameObject.name;
        }
        else if (UnlockType == Type.Hat)
        {
            SaveManager.save.currentHats.Add(gameObject.name);
        }

        SaveManager.save.Write();

        if (SaveManager.save.currentHats.Count > 1)
        {
            if (hatStackUnlocker == null)
            {
                hatStackUnlocker = AchievementUnlocker.MakeUnlocker("deckedout");
            }
            if (!triedHatStack)
            {
                hatStackUnlocker.UnlockAchievement();
                triedHatStack = true;
            }
        }

        foreach (Unlockable unlockable in FindObjectsOfType <Unlockable>())
        {
            unlockable.UpdateState();
        }
    }
    public void ShowUnlocks()
    {
        if (unlockUnlocker == null)
        {
            unlockUnlocker = AchievementUnlocker.MakeUnlocker("allunlocks");
            if (SaveManager.save.unlocks.Count == 13)
            {
                unlockUnlocker.UnlockAchievement();
            }
        }
        if (modalBlocker.raycastTarget)
        {
            return;
        }

        if (menuState == MainMenuState.WorldSelect)
        {
            menuState = MainMenuState.Between;
            StartCoroutine(PlayAnimation(animation, "LevelSelectToUnlocks", false, () =>
            {
                menuState = MainMenuState.Unlocks;
            }));
        }
    }
Beispiel #14
0
    void Update()
    {
        if (!triedUnlock && Speed > 300 && GetComponent <GrapplingHook>().IsGrappled)
        {
            AchievementUnlocker.MakeUnlocker("topspeed").UnlockAchievement();
            triedUnlock = true;
        }
        if (LevelStart.started && !LevelState.Dead)
        {
            float moment;

#if UNITY_ANDROID || UNITY_IPHONE
            foreach (Touch touch in Input.touches)
            {
                moment = touch.deltaPosition.x * 60.0f / Screen.dpi;

                if (touch.phase == TouchPhase.Moved && Time.timeScale > 0.0f)
                {
#else
            if (InputManager.dragging && Time.timeScale > 0.0f)
            {
                {
                    moment = InputManager.frameDifference.x * 0.25f * (1024.0f / (float)Screen.width);
#endif
                    angle = moment * sensitivityX;

                    angleChange += angle;

                    Quaternion a = Quaternion.Euler(0, angle, 0);

                    Vector3 outvec = a * GetComponent <Rigidbody>().velocity;

                    outvec.y = GetComponent <Rigidbody>().velocity.y;
                    GetComponent <Rigidbody>().velocity = outvec;

                    transform.rotation *= a;
                }
            }
        }
    }

    void FixedUpdate()
    {
        if (!LevelState.Dead && !LevelState.HasFinished && !GetComponent <Rigidbody>().isKinematic)
        {
            float speedloss = Mathf.Clamp01(((90.0f - Mathf.Abs(angleChange)) / 90.0f) + (SPEEDLOSS_THRERSHHERLD * Time.deltaTime));

            speedloss = 1.0f - (0.5f * (1.0f - speedloss));

            angleChange = 0.0f;

            Vector3 vel = GetComponent <Rigidbody>().velocity;
            vel  *= speedloss;
            vel.y = GetComponent <Rigidbody>().velocity.y;
            GetComponent <Rigidbody>().velocity = vel;

            float speed = vel.magnitude;
            if (SaveManager.save != null && speed > SaveManager.save.highestSpeed)
            {
                SaveManager.save.highestSpeed = speed;
            }
        }
    }
Beispiel #15
0
    public void Update()
    {
        GameObject targetedObjectPrev = targetedObject;

        if (IsGrappled)
        {
            hangTime += Time.deltaTime;
            if (hangTime > 30 && !triedHangUnlock)
            {
                hangUnlocker = AchievementUnlocker.MakeUnlocker("hanginout");
                hangUnlocker.UnlockAchievement();
                triedHangUnlock = true;
            }
        }
        else
        {
            hangTime = 0;
        }

        // Do gamepad input
        // Detarget
        if (!Input.GetButton("Target"))
        {
            targetedObject = null;
        }

        // Target
        if (Input.GetButton("Target"))
        {
            Vector3 position = new Vector3(Input.GetAxis("Horizontal2"),
                                           Input.GetAxis("Vertical2"),
                                           0);

            // Confirm axis to viewport space (-1..1 to 0..1)
            position += new Vector3(1.0f, 1.0f, 0);
            position /= 2.0f;

            // Find nearest object
            float      distance  = float.MaxValue;
            GameObject nearest   = null;
            Vector3    viewPoint = Vector3.zero;

            foreach (GameObject gameObject in grappleable)
            {
                Vector3 inputViewportPoint = position;
                inputViewportPoint.z = 0;

                Vector3 objectViewportPoint = theCamera.WorldToViewportPoint(gameObject.transform.position);
                objectViewportPoint.z = 0;

                float gObjDistance = (inputViewportPoint - objectViewportPoint).magnitude;

                if (gObjDistance < distance)
                {
                    distance  = gObjDistance;
                    nearest   = gameObject;
                    viewPoint = objectViewportPoint;
                }
            }

            if (nearest != null)
            {
                targetedObject = nearest;

                GrappleGuide grappleGuide = targetedObject.GetComponent <GrappleGuide>();
                if (grappleGuide != null)
                {
                    targetedObject = grappleGuide.grappleTo.gameObject;
                }
            }
        }

        // Update targeted object
        if (targetedObject != targetedObjectPrev)
        {
            string targetName = (targetedObject == null ?
                                 "null" : targetedObject.name);
            string oldTargetName = (targetedObjectPrev == null ?
                                    "null" : targetedObjectPrev.name);

            Debug.Log("New target: " + targetName +
                      ", Old target: " + oldTargetName);

            if (targetedObject != null)
            {
                GameObject realObject = targetedObject;

                realObject.GetComponent <Renderer>().material.SetColor("_OutlineColor", Color.red);
            }

            if (targetedObjectPrev != null)
            {
                GameObject realObject = targetedObjectPrev;

                realObject.GetComponent <Renderer>().material.SetColor("_OutlineColor", Color.white);
            }
        }

        if (!enabled)
        {
            return;
        }

        // Detatch
        if (LevelStart.started &&
            Input.GetButtonUp("Grapple"))
        {
            Detach();
        }

        // Attach
        if (LevelStart.started &&
            Input.GetButtonDown("Grapple") &&
            targetedObject != null)
        {
            Vector3 viewPoint = theCamera.WorldToViewportPoint(targetedObject.transform.position);

            Ray        ray = theCamera.ViewportPointToRay(viewPoint);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))            // && (enableRegrapple || rope.enabled == false))
            {
                if (hit.collider.gameObject != gameObject && hit.collider.gameObject.tag != "Ungrappleable")
                {
                    if (rope.enabled == true)
                    {
                        Detach();
                    }

                    Attach(hit, (transform.position - hit.point).magnitude, true);
                    SoundManager.Play("attach");
                }
            }
        }

        // Point the shield at the grapple point.
        if (rope.enabled)
        {
            // Point.
            shield.GetComponent <Renderer>().enabled = true;

            // Get the last point on the grapple.
            shield.transform.LookAt(grapples[grapples.Count - 1].gameObject.transform.position);
            shield.transform.Rotate(Vector3.right, 90);

//			// Widen the grapple the closer we are to our target.
//
//			// Get the distance between the .
//			float actualDistance = (transform.position - grapples[grapples.Count - 1].gameObject.transform.position).magnitude;
//			float distanceFration = actualDistance / grapples[grapples.Count - 1].maxDistance;
//
//			if(distanceFration < TRANSPARENCY_THRESHOLD)
//			{
//				ropeWidth = Mathf.Lerp(ropeWidth, ENABLED_THICKNESS, TRANSITION_RATE * Time.deltaTime);
//			}
//			else
//			{
//				ropeWidth = Mathf.Lerp(ropeWidth, DISABLED_THICKNESS, TRANSITION_RATE * Time.deltaTime);
//			}
//
//			rope.SetWidth(ropeWidth, ropeWidth);
        }
        else
        {
            shield.GetComponent <Renderer>().enabled = false;
        }

        if (!ControlManager.MouseOnGUI)
        {
            if (!TutorialCamera.Enabled() && !EndFlagScript.hasFinished && !PauseButton.paused)
            {
#if UNITY_ANDROID || UNITY_IPHONE
                Vector3 pos;

                foreach (Touch touch in Input.touches)
                {
                    if (touch.phase == TouchPhase.Began)
                    {
                        // Register touch
                        TouchData touchData = new TouchData();
                        touchData.fingerId  = touch.fingerId;
                        touchData.startTime = Time.time;

                        localTouches.Add(touchData);
                    }

                    if (touch.phase == TouchPhase.Ended)
                    {
                        TouchData touchData = null;
                        foreach (TouchData td in localTouches)
                        {
                            if (td.fingerId == touch.fingerId)
                            {
                                touchData = td;
                                break;
                            }
                        }

                        if (touchData != null)
                        {
                            pos = touch.position;

                            localTouches.Remove(touchData);

                            float startTime = touchData.startTime;
                            float endTime   = Time.time;

                            float touchTime = endTime - startTime;

                            // If the drag was less than the minimum time for grapple/ungrapple
                            if (touchTime < CLICK_TIMER)
                            {
                                if (!IsGrappling())
                                {
                                    TryGrapple(pos);
                                }
                                else
                                {
                                    Detach();
                                }
                            }
                        }
                    }
                }
#else
                if (InputManager.pressed)
                {
                    pressTime = Time.time;
                }

                if (InputManager.released)
                {
                    float touchTime = Time.time - pressTime;

                    if (touchTime < CLICK_TIMER)
                    {
                        if (!IsGrappling())
                        {
                            TryGrapple(Input.mousePosition);
                        }
                        else
                        {
                            Detach();
                        }
                    }
                }
#endif
            }
        }

        if (IsGrappling())
        {
            // Shrink rope for "easy mode"
            float dist = (grapple.transform.position - transform.position).magnitude;
            if (dist < springJoint.maxDistance)
            {
                springJoint.maxDistance = dist;
            }
        }
    }