예제 #1
0
    public override void Awake()
    {
        base.Awake();

        m_levelGoal = GetComponent <LevelGoal>();
        m_board     = GameObject.FindObjectOfType <Board>().GetComponent <Board>();
    }
예제 #2
0
    public void SetupStars(LevelGoal levelGoal)
    {
        if (levelGoal == null)
        {
            return;
        }

        m_levelGoal = levelGoal;

        m_maxScore = m_levelGoal.scoreGoals[m_levelGoal.scoreGoals.Length - 1];

        float sliderWidth = slider.GetComponent <RectTransform>().rect.width;

        if (m_maxScore > 0)
        {
            for (int i = 0; i < m_levelGoal.scoreGoals.Length; i++)
            {
                if (scoreStars[i] != null)
                {
                    float         newX          = (sliderWidth * m_levelGoal.scoreGoals[i] / m_maxScore) - (sliderWidth * 0.5f);
                    RectTransform starRectXform = scoreStars[i].GetComponent <RectTransform>();
                    if (starRectXform != null)
                    {
                        starRectXform.anchoredPosition = new Vector2(newX, starRectXform.anchoredPosition.y);
                    }
                }
            }
        }
    }
예제 #3
0
파일: ScoreMeter.cs 프로젝트: latarm/Match3
    public void SetupStars(LevelGoal levelGoal)
    {
        if (levelGoal == null)
        {
            Debug.LogWarning("SCOREMETER invalid level goal");
            return;
        }

        _levelGoal = levelGoal;

        _maxScore = _levelGoal.ScoreGoals[_levelGoal.ScoreGoals.Length - 1];
        float sliderWidth = Slider.GetComponent <RectTransform>().rect.width;

        if (_maxScore > 0)
        {
            for (int i = 0; i < levelGoal.ScoreGoals.Length; i++)
            {
                if (ScoreStars[i] != null)
                {
                    float         newX          = (sliderWidth * levelGoal.ScoreGoals[i] / _maxScore) - (sliderWidth * 0.5f);
                    RectTransform starRectXform = ScoreStars[i].GetComponent <RectTransform>();
                    if (starRectXform != null)
                    {
                        starRectXform.anchoredPosition = new Vector2(newX, starRectXform.anchoredPosition.y);
                    }
                }
            }
        }
    }
    public void SetupStars(LevelGoal levelGoal)
    {
        if (levelGoal == null)
        {
            Debug.LogWarning("Scoremeter: invalid level goal!");
            return;
        }

        this.levelGoal = levelGoal;

        maxScore = this.levelGoal.scoreGoals[this.levelGoal.scoreGoals.Length - 1];

        float sliderWidth = slider.GetComponent <RectTransform>().rect.width;

        if (maxScore > 0)
        {
            for (int i = 0; i < levelGoal.scoreGoals.Length; i++)
            {
                if (scoreStars[i] != null)
                {
                    float newX =
                        (sliderWidth * levelGoal.scoreGoals[i] / maxScore) - (sliderWidth * 0.5f);

                    RectTransform starRectXform = scoreStars[i].GetComponent <RectTransform>();

                    if (starRectXform != null)
                    {
                        starRectXform.anchoredPosition =
                            new Vector2(newX, starRectXform.anchoredPosition.y);
                    }
                }
            }
        }
    }
예제 #5
0
 // initialize components
 void Awake()
 {
     m_image     = GetComponent <Image>();
     m_rectXform = GetComponent <RectTransform>();
     m_board     = UnityEngine.Object.FindObjectOfType <Board>().GetComponent <Board>();
     m_levelGoal = GetComponent <LevelGoal>();
     buttonBuy   = boosterBuy.GetComponent <Button>();
 }
예제 #6
0
    public override void Awake()
    {
        base.Awake();
        m_levelGoal = GetComponent <LevelGoal>();

        //cache reference to goal
        m_board = FindObjectOfType <Board>().GetComponent <Board>();
    }
예제 #7
0
    IEnumerator Start()
    {
        if (segments.Count == 0)
        {
            throw new System.Exception("NOT ENOUGH SEGMENTS FOR THIS LEVEL - must be at least 1");
        }

        CurrentState = State.InProgress;

        while (CurrentState == State.InProgress)
        {
            if (LevelCasualties.current != null && LevelCasualties.current.TooManyCasualties)
            {
                CurrentState = State.Lost;
            }
            else if (currentGoal == null)
            {
                var segment = segments[currentIndex];
                currentGoal = segment.goal;


                //Crane.current.ResetCrane();
                ResetCrane();

                yield return(new WaitForSeconds(1f));

                var building = GameObject.Instantiate <Building>(segment.buildingPrefab);
                Crane.current.AttachBuilding(building);
                currentGoal.TargetBuilding = building;

                HideGoals();
                currentGoal.gameObject.SetActive(true);
            }
            else
            {
                if (currentGoal.IsSuccess)
                {
                    Crane.current.DetachBuilding(currentGoal.TargetBuilding);
                    if (currentIndex == (segments.Count - 1))
                    {
                        yield return(new WaitForSeconds(3f));

                        CurrentState = State.Won;
                    }
                    else
                    {
                        currentGoal = null;
                        currentIndex++;
                    }
                }
                else if (Crane.current.AttachedBuilding == null && Crane.current.TimeSinceDetached > 5f)
                {
                    CurrentState = State.Lost;
                }
            }
            yield return(null);
        }
    }
예제 #8
0
    public override void Awake()
    {
        base.Awake();
        DontDestroyOnLoad(this.gameObject);

        board              = FindObjectOfType <Board>().GetComponent <Board>();
        levelGoal          = GetComponent <LevelGoal>();
        levelGoalCollected = GetComponent <LevelGoalCollected>();
    }
예제 #9
0
 void Start()
 {
     eventSystem      = GameObject.Find("EventSystem").GetComponent <EventSystem>();
     sceneController  = GameObject.Find("SceneController").GetComponent <SceneController>();
     source           = GetComponent <AudioSource>();
     myCanvas         = GetComponent <Canvas>();
     goal             = GameObject.FindGameObjectWithTag("Goal").GetComponent <LevelGoal>();
     myCanvas.enabled = false;
 }
예제 #10
0
    public override void Awake()
    {
        base.Awake();

        // fill in LevelGoal and LevelGoalTimed components
        m_levelGoal      = GetComponent <LevelGoal>();
        m_levelGoalTimed = GetComponent <LevelGoalTimed>();

        // cache a reference to the Board
        m_board = GameObject.FindObjectOfType <Board>().GetComponent <Board>();
    }
    public void GoalReached(LevelGoal goal)
    {
        if (gameState != GameState.Playing)
        {
            return;
        }
        gameState = GameState.Done;
        float totalTime = Time.time - levelStartedAt;

        FindObjectOfType <UIAnimation>().LevelDone(totalTime);
        FindObjectOfType <Hero>().LevelComplete();
    }
        private void OnLevelLoaded(string levelName)
        {
            levelGoal = Resources.Load <LevelGoal>(levelName);

            enemiesKilled    = 0;
            pickupsCollected = 0;

            enemiesToKill = FindObjectsOfType <EnemyHealth>().Length;
            IPickupableItem[] pickups = FindObjectsOfType <Pickup>();
            pickupsToCollect = pickups
                               .Where(p => levelGoal.ContainsType(p.ItemInfo))
                               .Sum(p => p.Amount);
        }
예제 #13
0
  }                                                                // other classes access Levelgoal through gamemanager.



  public override void Awake() //already defined awake in levelgoal singleton, we have to override it. tile.cs and rectxformmover.
  {
      base.Awake();            //get all the logic from singleton base class. awake is earlier than stat.
      m_dataManager  = Object.FindObjectOfType <DataManager>();
      m_soundManager = Object.FindObjectOfType <SoundManager>();

      if (SceneManager.GetActiveScene().buildIndex > 1)
      {
          m_levelGoal = GetComponent <LevelGoal>();
          //   m_levelGoalTimed = GetComponent<LevelGoalTimed>(); // omitted because levelgoal class now has time related components.
          m_levelGoalCollected = GetComponent <LevelGoalCollected>();


          m_board = GameObject.FindObjectOfType <Board>().GetComponent <Board>();
      }
  }
예제 #14
0
    public override void Awake()
    {
        base.Awake();



        // fill in LevelGoal and LevelGoalTimed components
        m_levelGoal = GetComponent <LevelGoal>();
//        m_levelGoalTimed = GetComponent<LevelGoalTimed>();
        m_levelGoalCollected = GetComponent <LevelGoalCollected>();

        // cache a reference to the Board
        m_board = GameObject.FindObjectOfType <Board>().GetComponent <Board>();

        Chartboost.cacheInterstitial(CBLocation.Default);
    }
예제 #15
0
    public override void Awake()
    {
        base.Awake();

        LoadInfo.LoadData();

        // fill in LevelGoal and LevelGoalTimed components
        m_levelGoal = GetComponent <LevelGoal>();
//        m_levelGoalTimed = GetComponent<LevelGoalTimed>();
        m_levelGoalCollected = GetComponent <LevelGoalCollected>();

        // cache a reference to the Board
        m_board     = GameObject.FindObjectOfType <Board>().GetComponent <Board>();
        boosterTile = GetComponent <Tile>();
        IsGameOver  = false;
        m_isWinner  = false;
    }
예제 #16
0
    public void LevelCheck(LevelResults results, LevelGoal goal, int buildingBlock, LevelTopic topic)
    {
        print("Requested Level check from " + topic.ToString() + ": " + results.ToString() + ", " + goal.ToString() + ", " + buildingBlock.ToString());
        if ((results == LevelResults.Win && goal == LevelGoal.Win) ||
            (results == LevelResults.Fail && goal == LevelGoal.Fail) ||
            (results == LevelResults.Skip && goal == LevelGoal.Skip))
        {
            floors[nextfloor] = buildingBlock;

            /*print("House upgraded: "+ floors[0].ToString() + floors[1].ToString() + floors[2].ToString() + floors[3].ToString()
             + floors[4].ToString() + floors[5].ToString() + floors[6].ToString() + floors[7].ToString() + floors[8].ToString());*/
            nextfloor++;
        }
        completion[(int)topic] = true;
        print("Levels completed: " + completion[0].ToString() + completion[1].ToString() + completion[2].ToString()
              + completion[3].ToString() + completion[4].ToString() + completion[5].ToString() + completion[6].ToString()
              + completion[7].ToString() + completion[8].ToString());
    }
예제 #17
0
    // Start is called before the first frame update
    void Start()
    {
        Timer timer = GetComponentInChildren <Timer>(true);
        CollectionPanelSpawner collection = GetComponentInChildren <CollectionPanelSpawner>(true);

        timer.gameObject.SetActive(false);
        collection.gameObject.SetActive(false);

        LevelGoal goal = GameManager.Instance.GetComponent <LevelGoal>();

        if (goal is LevelGoalCollected)
        {
            collection.gameObject.SetActive(true);
        }
        else if (goal is LevelGoalTimed)
        {
            timer.gameObject.SetActive(true);
        }
    }
예제 #18
0
    // position the ScoreStars automatically
    public void SetupStars(LevelGoal levelGoal)
    {
        // if levelGoal is invalid, return immediately
        if (levelGoal == null)
        {
            Debug.LogWarning("SCOREMETER Invalid level goal!");
            return;
        }

        // cache the LevelGoal component for later
        this.levelGoal = levelGoal;

        // set the maximum score goal
        maxScore = this.levelGoal.scoreGoals[this.levelGoal.scoreGoals.Length - 1];

        // get the slider's RectTransform width
        float sliderWidth = slider.GetComponent <RectTransform>().rect.width;

        // avoid divide by zero error
        if (maxScore > 0)
        {
            // loop through our scoring goals
            for (int i = 0; i < levelGoal.scoreGoals.Length; i++)
            {
                // if the corresponding ScoreStar exists...
                if (scoreStars[i] != null)
                {
                    // set the x value based on the ratio of the scoring goal over the maximum score
                    float newX = (sliderWidth * levelGoal.scoreGoals[i] / maxScore) - (sliderWidth * 0.5f);

                    // move the ScoreStar's RectTransform
                    RectTransform starRectXform = scoreStars[i].GetComponent <RectTransform>();

                    if (starRectXform != null)
                    {
                        starRectXform.anchoredPosition = new Vector2(newX, starRectXform.anchoredPosition.y);
                    }
                }
            }
        }
    }
예제 #19
0
 public BaseGoalEvent(LevelGoal goal)
 {
     Goal = goal;
 }
예제 #20
0
 public GoalCompleteEvent(LevelGoal goal) : base(goal)
 {
 }
예제 #21
0
 //GUIText gt;
 // Use this for initialization
 void Start()
 {
     lg = FindObjectOfType <LevelGoal>();
     //gt = lg.GetComponent<GUIText>();
 }
예제 #22
0
 public void OnCoreTouchedGoal(LevelGoal goal)
 {
     if (!goalReachedCalled)
     {
         if (goal.unlockedAbility)
         {
             PlayerRecord.UnlockAbility(goal.unlockedAbility);
             Debug.Log("Goal reached, ability unlocked: " + goal.unlockedAbility.name);
         }
         else
         {
             Debug.Log("Goal reached");
         }
         eventDispatcher.FireEvent(LevelEventType.Goal);
         goalReachedCalled = true;
     }
     //TODO handle new level etc
     #if UNITY_EDITOR
     //UnityEditor.EditorApplication.isPaused = true;
     #endif
 }
예제 #23
0
 public GoalCreatedEvent(LevelGoal goal) : base(goal)
 {
 }
예제 #24
0
 public void mainMenu()
 {
     MainMenu.LS = "";
     LevelGoal.loadLevel("startscreen");
     PF_stuff.getleaderboard("hello");
 }
 public GoalIncrementEvent(LevelGoal goal, Bubble bubble, int score) : base(goal)
 {
     this.bubble = bubble;
     this.score  = score;
 }