示例#1
0
        public async Task XpGlobalLeaderboard(int page = 1)
        {
            if (--page < 0 || page > 100)
            {
                return;
            }
            var users = _service.GetUserXps(page);

            var embed = new EmbedBuilder()
                        .WithTitle(GetText("global_leaderboard"))
                        .WithOkColor();

            if (!users.Any())
            {
                embed.WithDescription("-");
            }
            else
            {
                for (int i = 0; i < users.Length; i++)
                {
                    var user = users[i];
                    embed.AddField(
                        $"#{(i + 1 + page * 9)} {(user.ToString())}",
                        $"{GetText("level_x", LevelStats.FromXp(users[i].TotalXp).Level)} - {users[i].TotalXp}xp");
                }
            }

            await Context.Channel.EmbedAsync(embed);
        }
示例#2
0
    public void EditLevel(string levelName, bool victory, float completionTime)
    {
        LevelStats ls = null;

        if (levelTable.ContainsKey(levelName))
        {
            ls = levelTable[levelName];
        }
        else
        {
            ls           = new LevelStats();
            ls.LevelName = levelName;
            levelTable.Add(levelName, ls);
        }

        if (victory)
        {
            ls.Victories++;
        }
        else
        {
            ls.Defeats++;
        }

        if (completionTime < ls.CompletionTime)
        {
            ls.CompletionTime = completionTime;
        }
    }
示例#3
0
    public void Win()
    {
        this.battleState = BattleState.YouWin;

        this.WinPanel.SetActive(true);

        int maxScore = this.players.Sum(x => x.Score);

        int emptyCellCount = GetEmptyCellCount();

        for (int i = 0; i < this.Grid.GetLength(0); i++)
        {
            for (int j = 0; j < this.Grid.GetLength(1); j++)
            {
                if (this.Grid[i, j] == null)
                {
                    emptyCellCount++;
                }
            }
        }

        LevelStats stats = new LevelStats(true, GameManager.Instance.CurrentLevel, this.currentPlayer.Score,
                                          maxScore, this.currentPlayer.StepCount, emptyCellCount);

        EventAggregator.OnLevelWon(stats);
    }
示例#4
0
    public void loadCustoms()
    {
        LevelStats stats = MainController.instance.getStats();

        Debug.Log("loadCustom");
        for (int i = 0; i < stats.collectedFruits.Length; i++)
        {
            Debug.Log("i" + " " + i + " " + stats.collectedFruits[i]);
        }
        string      str    = JsonUtility.ToJson(stats);
        HeroRefugee player = HeroRefugee.instance;

        LivesPanel.instance.setPause();

        PlayerPrefs.SetString(currentLevelName, str);
        PlayerPrefs.SetInt("health", LivesPanel.instance.getAmountOfHealth());
        x = player.transform.position.x;
        PlayerPrefs.SetFloat("x", x);
        y = player.transform.position.y;
        PlayerPrefs.SetFloat("y", y);
        z = player.transform.position.z;
        PlayerPrefs.SetFloat("z", z);

        PlayerPrefs.Save();

        SceneManager.LoadScene("Customs");
    }
示例#5
0
    public List <GameObject> GetRewards()
    {
        List <GameObject> rewards = new List <GameObject>();
        LevelStats        stats   = controller.GetPlayer().GetLevelStats();

        ConditionType  type       = rewardOneCondition;
        ComparisonType comparison = rewardOneComparison;
        float          value      = rewardOneValue;

        if (ConditionMet(stats, type, comparison, value))
        {
            rewards.Add(rewardOnePrefab);
        }

        type       = rewardTwoCondition;
        comparison = rewardTwoComparison;
        value      = rewardTwoValue;
        if (ConditionMet(stats, type, comparison, value))
        {
            rewards.Add(rewardTwoPrefab);
        }

        type       = rewardThreeCondition;
        comparison = rewardThreeComparison;
        value      = rewardThreeValue;
        if (ConditionMet(stats, type, comparison, value))
        {
            rewards.Add(rewardThreePrefab);
        }

        return(rewards);
    }
示例#6
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(this);
            Debug.LogError("More than one instance of FeedbackManager Script was found!");
        }

        getPHP            = GetComponent <GetPHP>();
        scoreTextAnimator = scoreText.gameObject.GetComponent <Animator>();
        chainTextAnimator = chainText.gameObject.GetComponent <Animator>();

        levelStatsData = new LevelStats(SceneLoader.instance.playingInfo.name,
                                        SceneLoader.instance.playingInfo.music,
                                        SceneLoader.instance.playingInfo.team,
                                        SceneLoader.instance.playingInfo.idSession);
        SetGradeTexts();
        SetMusicData();
        SetParticleSystemColor();
        state = uiState.PLAYING;
    }
示例#7
0
 public Character()
 {
     PInfoStats   = new InfoStats( );
     PLevelStats  = new LevelStats( );
     PPointStats  = new PointStats( );
     PCombatStats = new CombatStats( );
 }
示例#8
0
    public void FinishLevel(int boysCaught, int totalBoys, bool cigFound, bool lipstickFound) //called when you beat a level or whatever
    {
        print(save.currentLevel);
        LevelStats finishedLevel = save.levelByName[save.currentLevel];

        if (!finishedLevel.complete)
        {
            save.levelsComplete++;
            finishedLevel.complete = true;
        }
        finishedLevel.maxBoyCount = totalBoys;
        if (!finishedLevel.Cig && cigFound) //only set it if you haven't found it yet
        {
            finishedLevel.Cig = cigFound;
            save.magicNumber += cigPasswords[finishedLevel.levelName]; //for "verification"
            print("does happon?");
        }
        if (!finishedLevel.Lipstick)
        {
            finishedLevel.Lipstick = lipstickFound;
        }

        if (boysCaught > finishedLevel.highestBoyCount) //only set it if it's higher than before
        {
            finishedLevel.highestBoyCount = boysCaught;
        }
        finishedLevel.latestTime = Time.time - startLevelTime;
        if ((finishedLevel.latestTime < finishedLevel.fastestTime) || finishedLevel.fastestTime == 0f)
        {
            finishedLevel.fastestTime = finishedLevel.latestTime;
        }
        WriteSaveToFile();
    }
示例#9
0
    public LevelStats generateStats()
    {
        LevelStats stats = new LevelStats();

        if (currentLevel >= minLevel_ghost)
        {
            stats.totalMonsters += mobGhosts;
        }
        if (currentLevel >= minLevel_wizard)
        {
            stats.totalMonsters += mobWizards;
        }
        if (currentLevel >= minLevel_ogre)
        {
            stats.totalMonsters += mobOgres;
        }
        stats.killedMonsters = stats.totalMonsters - GameObject.FindGameObjectsWithTag("Enemy").Length;

        stats.totalHealthPotions = healthPotions;
        stats.drankHealthPotions = stats.totalHealthPotions - GameObject.FindGameObjectsWithTag("HealthPotion").Length;

        stats.totalManaPotions = manaPotions;
        stats.drankManaPotions = stats.totalManaPotions - GameObject.FindGameObjectsWithTag("ManaPotion").Length;

        stats.levelScore = (stats.killedMonsters * enemyKilledPoints) + ((stats.drankHealthPotions + stats.drankManaPotions) * potionDrankPoints);


        Debug.Log("Killed " + stats.killedMonsters + " out of " + stats.totalMonsters);
        Debug.Log("Score is " + stats.levelScore);

        return(stats);
    }
示例#10
0
    public LevelStats LoadGame(string mapName, out LevelStats stats)
    {
        CreateDirectories();

        LevelStats temp = new LevelStats();

        stats = null;
        BinaryFormatter binaryFormatter = new BinaryFormatter();

        if (!Directory.Exists($"{Application.persistentDataPath}{gameDir}/{mapName}"))
        {
            Directory.CreateDirectory($"{Application.persistentDataPath}{gameDir}/{mapName}");
            return(null);
        }


        if (File.Exists($"{Application.persistentDataPath}{gameDir}/{mapName}/save.txt"))
        {
            FileStream file = File.Open($"{Application.persistentDataPath}{gameDir}/{mapName}/save.txt", FileMode.Open);
            JsonUtility.FromJsonOverwrite((string)binaryFormatter.Deserialize(file), temp);
            file.Close();
        }
        stats = temp;
        return(temp);
    }
示例#11
0
    private void Start()
    {
        LevelStats = new LevelStats(this);
        LevelStats.Init();

        Init();
    }
示例#12
0
    public void ShowGameCompleteMenu(LevelStats stats)
    {
        showingComplete    = true;
        InGameMenu.enabled = true;
        ContinueButton.gameObject.SetActive(false);
        NextLevelButton.gameObject.SetActive(stats.RedStars > 0 && GameController.instance.HasMoreLevels() && stats.Completed);

        if (NextLevelButton.gameObject.activeInHierarchy)
        {
            NextLevelButton.Select();
        }
        else
        {
            RetryButton.Select();
        }

        if (stats.RedStars > 0 && stats.Completed)
        {
            Title.text = "Level \"" + stats.LevelName + "\" Completed!";
        }
        else
        {
            Title.text = "Level " + stats.LevelName + " Failed";
        }

        Stats.text = "Red Stars: " + stats.RedStars + "  Yellow Stars: " + stats.YellowStars;
    }
    /// <summary>
    /// Ensure the level manager is not null
    /// </summary>
    private void LazyLoad()
    {
        if (LevelManager == null && (LevelManager.instanceExists))
        {
            LevelManager = LevelManager.instance;
        }
        stats          = LevelManager.LevelStats;
        elapsedMinutes = (int)(stats.time) / 60;
        elapsedSeconds = (int)(stats.time) % 60;

        seconds = elapsedSeconds < 10 ? "0" + elapsedSeconds.ToString() : elapsedSeconds.ToString();

        levelXP   = stats.rewardedXP + stats.totalXP;
        levelGold = stats.rewardedGold + stats.goldEarned;
        levelGems = stats.rewardedGems + stats.gemsEarned;

        xpToNextLevel = Player.Experience.GetExperienceToNextLevel();

        stats.shotAccuracy = (stats.hits / stats.totalShots) * 100f;

        Debug.Log("Hits : " + stats.hits);
        Debug.Log("TotalShots : " + stats.totalShots);

        float levelTime     = LevelManager.LevelTime;
        float remainingTime = levelTime - stats.time;

        stats.score = (int)(1.5f * (stats.shotAccuracy * remainingTime * 0.025f) + stats.damageDone * 0.5);
    }
示例#14
0
 public static void OnLevelWon(LevelStats stats)
 {
     if (LevelWon != null)
     {
         LevelWon(stats);
     }
 }
示例#15
0
    private void Awake()
    {
        LevelStats stats = LevelStats.Load(levelName);

        if (stats == null)
        {
            stats = new LevelStats();
        }

        if (stats.hasCrystals)
        {
            crystal.sprite = allCrystals;
            crystal.GetComponent <Transform>().localScale = new Vector3(.7f, .7f, 1f);
        }
        if (stats.hasAllFruits)
        {
            fruit.sprite = allFruits;
            fruit.GetComponent <Transform>().localScale = new Vector3(.8f, .8f, 1f);
        }
        if (LevelStats.Load(prevLevel) != null)
        {
            isOpen = LevelStats.Load(prevLevel).levelPassed;
        }
        doorLock.enabled = !isOpen;
        check.enabled    = stats.levelPassed;
    }
示例#16
0
        public bool CreateClub(IUser user, string clubName, out ClubInfo club)
        {
            //must be lvl 5 and must not be in a club already

            club = null;
            using (var uow = _db.UnitOfWork)
            {
                var du = uow.DiscordUsers.GetOrCreate(user);
                uow._context.SaveChanges();
                var xp = new LevelStats(uow.Xp.GetTotalUserXp(user.Id));

                if (xp.Level >= 5 && du.Club == null)
                {
                    du.Club = new ClubInfo()
                    {
                        Name    = clubName,
                        Discrim = uow.Clubs.GetNextDiscrim(clubName),
                        Owner   = du,
                    };
                    uow.Clubs.Add(du.Club);
                    uow._context.SaveChanges();
                }
                else
                {
                    return(false);
                }

                uow._context.Set <ClubApplicants>()
                .RemoveRange(uow._context.Set <ClubApplicants>().Where(x => x.UserId == du.Id));
                club = du.Club;
                uow.Complete();
            }

            return(true);
        }
    IEnumerator <WaitForSeconds> PlayScore(LevelStats stats, System.Action callback)
    {
        container.SetActive(true);
        int totalScore = 0;
        int partScore  = 0;

        yield return(new WaitForSeconds(playScoreDelay));

        partScore          = Mathf.Max(0, 4 - stats.captures) * 100;
        capturesValue.text = partScore.ToString();
        totalScore        += partScore;
        yield return(new WaitForSeconds(playScoreDelay));

        partScore       = Mathf.Max(0, 40 - stats.turns) * 10;
        turnsValue.text = partScore.ToString();
        totalScore     += partScore;
        yield return(new WaitForSeconds(playScoreDelay));

        partScore       = Mathf.Max(0, 80 - stats.steps) * 10;
        stepsValue.text = partScore.ToString();
        totalScore     += partScore;
        yield return(new WaitForSeconds(playScoreDelay));

        partScore          = stats.escapees * 200;
        escapeesValue.text = partScore.ToString();
        totalScore        += partScore;
        yield return(new WaitForSeconds(playScoreDelay));

        totalValue.text = totalScore.ToString();
        totalScorer.AddScore(totalScore);
        yield return(new WaitForSeconds(finalDelay));

        container.SetActive(false);
        callback();
    }
示例#18
0
    public void GetRankings(LevelStats l1, Dictionary <string, LevelStats> dic)
    {
        LevelRanking pbRanking = l1.GetLevelRanking(dic);

        Debug.Log(l1);
        Debug.Log(string.Format("Time: {0}, Blocks Used: {1}, Blocks Collected: {2}", pbRanking.CompletionTime, pbRanking.BlocksUsed, pbRanking.BlocksCollected));
    }
示例#19
0
    public bool Save()
    {
        var ps = new PlayerStats();

        ps.Name               = Name;
        ps.MultiplayerWins    = MultiplayerWins;
        ps.MultiplayerDefeats = MultiplayerDefeats;

        var lsl = new LevelStats[levelTable.Count];
        int i   = 0;

        foreach (var l in levelTable.Values)
        {
            lsl[i] = l;
            i++;
        }
        ps.LevelStatsList = lsl;

        string dataStr = JsonUtility.ToJson(ps);

        PlayerPrefs.SetString("PlayerStats", dataStr);
        //Debug.Log("Saved Data: " + dataStr);

        //Debug.Log("PlayerData: " + dataStr);
        //PlayerPrefs.SetString(DisplayNameKey, Name);
        //PlayerPrefs.SetInt(MultiplayerWinsKey, MultiplayerWins);
        //PlayerPrefs.SetInt(MultiplayerDefeatsKey, MultiplayerDefeats);
        return(true);
    }
示例#20
0
    public void MoreCollected(LevelStats l1, LevelStats l2)
    {
        Debug.Log("l2 collected more blocks than l1");

        LevelStats comparer = new LevelStats();
        LevelStats newpb    = LevelStats.GetLowest(l1, l2, ref comparer);

        if (comparer.Time < 0 && comparer.BlocksUsed < 0 && comparer.BlocksCollected.Collected > 0)
        {
            Debug.Log("Comparer results correct");
        }
        else
        {
            Debug.Log("Comparer results correct");
        }

        if (newpb.Time == l1.Time && newpb.BlocksUsed == l1.BlocksUsed && newpb.BlocksCollected.Collected == l2.BlocksCollected.Collected)
        {
            Debug.Log("Properties match");
        }
        else
        {
            Debug.Log("Property mismatch");
        }
    }
示例#21
0
    void loadIt(LevelStats stats)
    {
        Debug.Log(lvlNumber);

        var fruits   = GameObject.Find("fruits_" + lvlNumber).GetComponent <SpriteRenderer>();
        var gems     = GameObject.Find("gems_" + lvlNumber).GetComponent <SpriteRenderer>();
        var finished = GameObject.Find("finished_" + lvlNumber).GetComponent <SpriteRenderer>();



        if (stats == null)
        {
            finished.sprite = null;
            return;
        }


        if (stats.hasAllFruits)
        {
            fruits.sprite = rdyFruit;
        }

        if (stats.hasCrystals)
        {
            gems.sprite = rdyGems;
        }


        if (!stats.levelPassed)
        {
            finished.sprite = null;
        }
    }
示例#22
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        HeroRabit rabit = collider.GetComponent <HeroRabit>();

        if (rabit != null)
        {
            LevelStats stats = LevelController.current.getStats();
            if (stats == null)
            {
                Debug.Log("Statsk is null");
            }
            stats.levelPassed = true;

            if (FruitsController.controller.allCollected())
            {
                stats.hasAllFruits = true;
            }

            PlayerPrefs.SetInt("coins", CoinsController.controller.getCoins());
            //string str = JsonUtility.ToJson(stats);
            ///PlayerPrefs.SetString(currentLevelName, str);

            PlayerPrefs.Save();

            GameObject parent = UICamera.first.transform.parent.gameObject;
            GameObject obj    = NGUITools.AddChild(parent, winPrefab);
            WinPopup   popup  = obj.GetComponent <WinPopup>();
        }
    }
示例#23
0
    /// <summary>
    /// Compares completion time, blocked used, and blocks collected for l1 and l2
    /// </summary>
    /// <param name="l1"></param>
    /// <param name="l2"></param>
    /// <param name="compareResult">+1 is returned for each parameter that l2 was better</param>
    /// <returns></returns>
    public static LevelStats GetLowest(LevelStats l1, LevelStats l2, ref LevelStats compareResult)
    {
        LevelStats lsr = l1.Clone() as LevelStats;

        //if l2 was completed faster than l1, make l2 new lowest
        if (l2.Time < lsr.Time)
        {
            lsr.Time           = l2.Time;
            compareResult.Time = 1;
        }
        //if l2 used less blocks than l1, make l2 new lowest
        if (l2.BlocksUsed < lsr.BlocksUsed)
        {
            lsr.BlocksUsed           = l2.BlocksUsed;
            compareResult.BlocksUsed = 1;
        }
        //if l2 collected more blocks than l1, make l2 new highest
        if (l2.BlocksCollected.Collected > lsr.BlocksCollected.Collected)
        {
            lsr.BlocksCollected.Collected           = l2.BlocksCollected.Collected;
            compareResult.BlocksCollected.Collected = 1;
        }

        return(lsr);
    }
示例#24
0
    public void SetStats(LevelStats stats)
    {
        switch (stats.thisLevel)
        {
        case LevelToUnlock.airLevel:
            AirLevelStats = stats;
            break;

        case LevelToUnlock.earthLevel:
            EarthLevelStats = stats;
            break;

        case LevelToUnlock.fireLevel:
            FireLevelStats = stats;
            break;

        case LevelToUnlock.iceLevel:
            WaterLevelStats = stats;
            break;

        case LevelToUnlock.tutorial:
            TutorialLevelStats = stats;
            break;
        }
    }
示例#25
0
    public void CompleteLevel()
    {
        //set new PBs
        LevelStats pb;
        LevelStats comparer = new LevelStats();

        //set the global PB to be the new PB if better
        pb = GlobalManager.Instance.LevelCompletionStats[LevelNumber]["PB"];
        pb = LevelStats.GetLowest(pb, currentStats, ref comparer);

        //play animation for improved pb categories
        if (comparer.Time > 0)
        {
        }
        if (comparer.BlocksCollected.Collected > 0)
        {
        }
        if (comparer.BlocksUsed > 0)
        {
        }

        //check the rankings of the new PB
        LevelRanking pbRanking = pb.GetLevelRanking(GlobalManager.Instance.LevelCompletionStats[LevelNumber]);

        //display animations for rankings

        //Save Game
        GlobalManager.Instance.SaveGame();
    }
    public List <LevelStats> levelStats;                    // List of level stats of each level.

    //Get the LevelStats of level by nameLevel
    public LevelStats GetLevelStats(string nameLevel)
    {
        LevelStats data = new LevelStats();

        //Load if the levelStats is null
        if (levelStats == null)
        {
            LoadStats();
        }

        int index = this.levelStats.FindIndex(x => x.nameLevel == nameLevel);

        //Initialize if the levelStats don't exist
        if (index == -1)
        {
            data.nameLevel  = nameLevel;
            data.higthScore = 0;
            this.levelStats.Add(data);
            SaveStats();
        }
        else
        {
            data = this.levelStats[index];
        }
        return(data);
    }
示例#27
0
 private void UpdateFinishLevel()
 {
     currentLevelStats.StopTime();
     levelsStats.Add(currentLevelStats);
     print(currentLevelStats);
     currentLevelStats = null;
 }
示例#28
0
        void reverseChase()
        {
            _blinkyTimer = new EggTimer(4600.Milliseconds(), () => { });

            _pacTimer = new EggTimer(4350.Milliseconds(), async() =>
            {
                _finished = true;
                await _mediator.Publish(new CutSceneFinishedEvent());
            });

            _pacMan.Visible    = false;
            _bigPacMan.Visible = true;

            var s    = new LevelStats(0);
            var sess = new GhostFrightSession(s.GetLevelProps());

            _blinky.Direction = new DirectionInfo(Directions.Right, Directions.Right);
            _blinky.SetFrightSession(sess);
            _blinky.SetFrightened();
            _blinkyPositions = _blinkyPositions.Reverse();

            var bigPacPos = _pacPositions.Reverse();

            bigPacPos = new StartAndEndPos(bigPacPos.Start - new Vector2(100, 0), bigPacPos.End);

            _pacPositions = bigPacPos;
        }
示例#29
0
    private void EventAggregator_LevelWon(LevelStats stats)
    {
        this.levelStats[this.CurrentLevel] = stats;

        this.gameSaver.Save(new List <LevelStats>(this.levelStats.Values).ToArray());

        RecalcBlockLevels();
    }
示例#30
0
 public LevelStats(LevelStats aLevelStats)
 {
     coins        = aLevelStats.coins;
     pointsNormal = aLevelStats.pointsNormal;
     pointsExtra  = aLevelStats.pointsExtra;
     isPerfect    = aLevelStats.isPerfect;
     valid        = aLevelStats.valid;
 }
 private void Awake()
 {
     jump = (AudioClip)Resources.Load ("SoundFX/player_jump");
             enemy_death = (AudioClip)Resources.Load ("SoundFX/enemy_death");
             levelStats = GameObject.Find ("LevelLogic").GetComponent<LevelStats> ();
             audio_source = GetComponent<AudioSource> ();
             ray_length = 0.3f; //GetComponent<Renderer> ().bounds.size.x / 2*5;
             ray_height = 0.40f;// (GetComponent<Renderer> ().bounds.size.y/2)*5;
             anim = GetComponent<Animator> ();
 }
示例#32
0
	void Awake()
	{

		if (isTimed) 
		{
			myCountDownTimerRef = GameObject.Find("TimerLabel").GetComponent<CountDownTimer>();
		}
		myLevelStatsRef = this.gameObject.GetComponent<LevelStats>();
		// Automatic find game objects and references
		myDrinksContainerRef = GameObject.Find("_DrinksContainer").GetComponent<DrinksContainer>();
		mySeatsRef = GameObject.Find("_Seats").GetComponent<Seats>();
		drinkSpawner = GameObject.Find("DrinkSpawner").transform;
	}
示例#33
0
 void Awake()
 {
     audio_source = GetComponent<AudioSource> ();
     shotFX = (AudioClip)Resources.Load ("SoundFX/enemy_shoot");
     frogJumpFX = (AudioClip)Resources.Load ("SoundFX/frog_jump");
     level_stats = GameObject.Find ("LevelLogic").GetComponent<LevelStats> ();
     player = GameObject.FindGameObjectWithTag ("Player").GetComponent<PlayerMovement2D> ();
     anim = GetComponent<Animator> ();
 }
示例#34
0
 void Awake()
 {
     enemy_spawn = (GameObject)Resources.Load ("Enemy/EnemySpawn");
             level_stats = GameObject.Find ("LevelLogic").GetComponent<LevelStats> ();
 }
	// Use this for initialization
	void Awake (){
		
		//get level data
		var lvlPL=GameObject.FindGameObjectWithTag("LevelPlaylist").GetComponent<LevelPlaylist>();
		var lvlDB=GameObject.FindGameObjectWithTag("EntityDatabase").GetComponent<LevelDatabase>();
		stats=lvlDB.getLevel(lvlPL.getCurrentLevelName());
		
		//var spawn_positions=new List<Tile>();
		
		mesh_bounds=tile_mesh.renderer.bounds;
		main_camera=GameObject.Find("Main Camera").GetComponent<CameraScript>();
		main_camera.DetachPlane();
		
		
		var hexa_size=mesh_bounds.size;
		
		terrain=new Tile[LevelWidth,LevelHeight];
		
		var pos=Vector3.zero;
		float tile_w=hexa_size.x,tile_h=hexa_size.z;//ground_prefab.transform.localScale.x
		
		
		
		//creating tiles
		Vector3 coor=new Vector3(0,0,0);
		
		for (int i=0;i<terrain.GetLength(0);i++)
		{
			if (i%2!=0)
				pos.z=tile_h/2;
			else
				pos.z=0;
			
			if (i!=0&&(i%2==0)){
				coor.x-=1;
			}
			coor.y=i;
			
			for (int j=0;j<terrain.GetLength(1);j++)
			{
				var tile=Instantiate(ground_prefab,pos,Quaternion.identity) as Transform;
				tile.transform.parent=transform;
				var ts=tile.GetComponent("Tile") as Tile;
				terrain[i,j]=ts;
				tiles.Add(ts);
				ts.setCoordinate(new Vector3(coor.x+j,coor.y,-((coor.x+j)+coor.y)));
				
				if (Subs.RandomPercent()<stats.Tile_random_low_change){
					ts.Tile_Data.setMovementBounds(stats.Tile_random_low_height,0f);
					ts.Tile_Data.setTimeBounds(stats.Tile_random_time_min,stats.Tile_random_time_max,true);
				}
				
				if (Subs.RandomPercent()<stats.Tile_random_high_change){
					ts.Tile_Data.setMovementBounds(stats.Tile_random_high_height,0f);
					ts.Tile_Data.setTimeBounds(stats.Tile_random_time_min,stats.Tile_random_time_max,true);
				}

				pos.z+=tile_h+0.01f;
			}
			//pos.x+=tile_w+(tile_w*0.5f);
			pos.x+=tile_w*(3f/4f);
		}
		//load land shape DEV. circle
		
		int xx=terrain.GetLength(0)/2,yy=terrain.GetLength(1)/2;
		center_point=terrain[xx,yy].getCoordinate();
		var radius=xx-1;
		
		
		
		for (int i=0;i<terrain.GetLength(0);i++)
		{
			for (int j=0;j<terrain.GetLength(1);j++)
			{
				var ts=terrain[i,j];
				if (!HexaDistanceInside(center_point,ts.getCoordinate(),radius)){
					ts.gameObject.SetActive(false);
				}					
			}
		}
		
		//group up tiles
		int group_amount=radius+1;
		for (int g=0;g<group_amount;g++){
			radius=(group_amount-g);
			var data=new TileData(Vector3.zero,g);
			data.setMovementBounds(0.03f,0.03f);
			data.setTimeBounds(1000,1000,true);
			tile_groups.Add(data);
			
			foreach (var ts in tiles){
				if (HexaDistanceInside(center_point,ts.getCoordinate(),radius)){
					ts.setTileGroup(data);
				}
			}
		}
		terrain[xx,yy].setTileGroup(null);//center not moving
		terrain[xx,yy].Tile_Data.Activate(false);
		
		main_camera.setMiddlePos(terrain[xx,yy].transform.position);
		
		terrain_timer=new Timer(stats.Terrain_deterioration_time,OnTerrainTrigger);
		
		//main_camera.transform.position=new Vector3(terrain[xx,yy].transform.position.x,main_camera.transform.position.y,main_camera.transform.position.z);
		//main_camera.LookAtCenter(terrain[xx,yy].transform.position);
		main_camera.DetachPlane();
		
		//pause level
		Activate(false);
		
		foreach (var t in tile_groups){
			t.Activate(false);
		}
	}
示例#36
0
        void GetLevelStats()
        {
            LevelStat = new LevelStats[32];

            for(int i = 0; i < 32; ++i)
                LevelStat[i] = new LevelStats();

            LevelStat[0].locked = false;
            LevelStat[0].passed = false;

            LevelStat[20].locked = false;
            LevelStat[20].passed = false;
        }
示例#37
0
        ///<summary>Calculate level stats - number of cell of each type</summary>
        public LevelStats CalcLevelStats()
        {
            LevelStats uRv = new LevelStats();

            for (int i = 0; i < iXsize; i++)
                for (int j = 0; j < iYsize; j++)
                    switch (bCells[i, j]&SokoCell.FilterSkipCellDeadlocks)
                    {
                        case SokoCell.Box://Only box
                            uRv.iNumBoxes++;
                            break;
                        case SokoCell.BoxOnTarget://Box and target and box-on-target
                            uRv.iNumBoxes++;
                            uRv.iNumTargets++;
                            uRv.iNumBoxesOnTargets++;
                            break;
                        case SokoCell.PlayerOnTarget://Player and target
                            uRv.iNumTargets++;
                            uRv.iNumPlayers++;
                            break;
                        case SokoCell.Target://Only target
                            uRv.iNumTargets++;
                            break;
                        case SokoCell.Player://Only player
                            uRv.iNumPlayers++;
                            break;
                        case SokoCell.Empty://Only Empty
                            uRv.iNumEmpty++;
                            break;
                        case SokoCell.Wall://Only wall
                            uRv.iNumWalls++;
                            break;
                        case SokoCell.Background://Only background
                            uRv.iNumBackground++;
                            break;
                    }
            return uRv;
        }
示例#38
0
 void Start()
 {
     level_stats = gameObject.GetComponent<LevelStats> ();
 }