Ejemplo n.º 1
0
    public void Start()
    {
        currentPart = 0;
        GameEventSystem.OnGameEventRaised += HandleGameEvents;
        playerGO = GameObject.FindGameObjectWithTag("Player");
        if (playerGO == null)
        {
            Debug.LogError("Player GO is null in Level Controller");
        }
        else
        {
            playerGO.SetActive(false);
        }
        levelUpdate = GetComponent <LevelUpdate>();
        if (levelUpdate == null)
        {
            Debug.LogError("Level update is null. Is it attached in the same GO as Level Controller?");
        }
        if (levelDataSO == null)
        {
            Debug.LogError("Level Data SO is null");
        }
        else
        {
            localLevelData = LevelHelper.GetLocalLevelData(levelDataSO.levelData.id);
        }

        Invoke("StartLevel", 1f);
    }
Ejemplo n.º 2
0
    public bool CanMove(int fromX, int fromY, Orientation toOrientation)
    {
        int toX = fromX;
        int toY = fromY;

        LevelHelper.GetNextCellCoords(ref toX, ref toY, toOrientation);

        Debug.Log("CanMove fromX=" + fromX + "/ fromY=" + fromY + " / toX=" + toX + " / toY=" + toY);

        Object obj = GetObjectAtPos(toX, toY);

        if (obj != null)
        {
            return(obj.isTraversable());
        }
        else
        {
            // check for out of map

            if (toX < m_Tile.origin.x ||
                toX >= (m_Tile.origin.x + m_Tile.size.x) ||
                toY < m_Tile.origin.y ||
                toY >= (m_Tile.origin.y + m_Tile.size.y))
            {
                return(false);
            }

            // check for out of map
        }
        return(true);
    }
Ejemplo n.º 3
0
 public AlienStateCatched(Alien alien, Settings settings, AlienCatchedSignal catchedSignal, LevelHelper levelHelper)
 {
     _alien       = alien;
     _settings    = settings;
     _catched     = catchedSignal;
     _levelHelper = levelHelper;
 }
Ejemplo n.º 4
0
    public void Construct(
        LevelHelper level
        )
    {
        _level = level;

        _childList = new List <Transform>();
        _childOriginalPositionList = new List <Vector3>();

        //register child
        foreach (Transform child in transform)
        {
            _childList.Add(child);
        }

        if (AutoCloneChild)
        {
            Transform original   = _childList.FirstOrDefault();
            Transform dupplicate = Instantiate(original);
            dupplicate.SetParent(original.parent, false);

            dupplicate.MoveToRight(original, GetSpace());
            _childList.Add(dupplicate);
        }

        _childList = _childList.OrderBy(child => child.position.x).ToList();
        _childOriginalPositionList = _childList.Select(child => child.transform.position).ToList();
    }
Ejemplo n.º 5
0
    /// <summary>
    /// Update is called every frame, if the MonoBehaviour is enabled.
    /// </summary>
    void Update()
    {
        if (Input.GetKey(KeyCode.Mouse1))
        {
            float horizontal = Input.GetAxis("Mouse X") * Time.deltaTime * 50 * -1;
            float vertical   = Input.GetAxis("Mouse Y") * Time.deltaTime * 50 * -1;
            transform.Translate(new Vector3(horizontal, vertical));
        }

        CameraHelper cameraHelper = new CameraHelper(Camera.main);
        LevelHelper  levelHelper  = new LevelHelper(bottomLeftCorner, topRightCorner);

        if (cameraHelper.left < levelHelper.left)
        {
            cameraHelper.center.x = levelHelper.left + cameraHelper.width / 2;
        }
        else if (cameraHelper.right > levelHelper.right)
        {
            cameraHelper.center.x = levelHelper.right - cameraHelper.width / 2;
        }

        if (cameraHelper.top > levelHelper.top)
        {
            cameraHelper.center.y = levelHelper.top - cameraHelper.height / 2;
        }
        else if (cameraHelper.bottom < levelHelper.bottom)
        {
            cameraHelper.center.y = levelHelper.bottom + cameraHelper.height / 2;
        }

        transform.position = new Vector3(cameraHelper.center.x, cameraHelper.center.y, transform.position.z);
    }
Ejemplo n.º 6
0
 /// <summary>
 /// init value for play next level
 /// </summary>
 private void playNextLevel()
 {
     levelInfo = LevelHelper.getNextLevel();
     InitNode();
     setNodeStartLevel();
     refreshNodeState();
 }
Ejemplo n.º 7
0
    private void OnLevelEnd(bool has_won)
    {
        GameEventSystem.RaiseGameEvent(GAME_EVENT.GAME_PAUSED);
        int money_earned = 0;

        if (has_won)
        {
            Debug.Log("WON !");
            if (localLevelData != null)
            {
                money_earned = ScoreManager.GetTotalMoney(localLevelData.completed);
                LevelHelper.UpdateLevel(localLevelData.id, true, money_earned);
                LevelHelper.SaveLevelData();
                InventoryHelper.UpdateMoney(money_earned);
                InventoryHelper.SavePlayerData();
                PlayerPrefs.SetInt("last_level_id", localLevelData.id);
            }
            else
            {
                Debug.LogError("Cannot update level, levelData is null");
            }
        }
        else
        {
            playerGO.GetComponent <PlayerController>().OnPlayerDead();
            Debug.Log("LOST");
        }

        if (LevelUIManager.instance != null)
        {
            StartCoroutine(LevelUIManager.instance.ShowGameOverScreen(has_won, money_earned));
        }
    }
Ejemplo n.º 8
0
 public void Construct(LevelHelper level, Settings settings)
 {
     _level     = level;
     _settings  = settings;
     _rigidBody = GetComponent <Rigidbody2D>();
     _sprite    = GetComponentInChildren <SpriteRenderer>();
 }
Ejemplo n.º 9
0
Archivo: Main.cs Proyecto: WeeirJoe/Joe
 void Init()
 {
     GameStateMgr.LoadState();
     DataMgr.LoadAllData();
     SoundManager.Init();
     DialogStateManager.Init();
     PopupStateManager.Init();
     PersistMgr.Init();
     UnityEngine.Random.InitState((int)System.DateTime.UtcNow.Ticks);
     if (!launchSingle)
     {
         //检查更新,进入主界面
         DialogStateManager.ChangeState(DialogStateManager.ConnectDialogState);
         GameStart();
     }
     else
     {
         //如果当前场景就是关卡场景,那么直接调用,否则需要先加载对应的关卡场景
         if (Loader.Instance == null)
         {
             LevelData lev = Ins.DataMgr.GetLevelData(level);
             U3D.LoadScene(lev.Scene, () => {
                 LevelHelper.OnLoadFinishedSingle(level);
             });
         }
         else
         {
             LevelHelper.OnLoadFinishedSingle(level);
         }
     }
 }
Ejemplo n.º 10
0
 public AsteroidManager(
     Settings settings, Asteroid.Factory asteroidFactory, LevelHelper level)
 {
     _settings = settings;
     _timeIntervalBetweenSpawns = _settings.maxSpawnTime / (_settings.maxSpawns - _settings.startingSpawns);
     _timeToNextSpawn           = _timeIntervalBetweenSpawns;
     _asteroidFactory           = asteroidFactory;
     _level = level;
 }
Ejemplo n.º 11
0
    protected override void Execute()
    {
        bool currentSceneIsALevel = LevelHelper.CheckIfLevelExistsWithScene(scene);

        if (!currentSceneIsALevel)
        {
            Abort();
        }
    }
Ejemplo n.º 12
0
    public void ApplyLevelProgressState()
    {
        if (!LevelHelper.CheckIfLevelExistsWithNumber(levelNumber))
        {
            levelProgressState = LevelProgressState.Unset;
        }

        spriteRenderer.color = LevelStatusAppearances.LevelStatusColors[(int)levelProgressState];
    }
Ejemplo n.º 13
0
    protected override void Execute()
    {
        int levelNumber = LevelHelper.GetNumberOfLevelWithScene(sceneStatus.currentScene);

        if (!gameStateModel.Get().CompletedLevels.Contains(levelNumber))
        {
            gameStateModel.Get().CompletedLevels.Add(levelNumber);
        }
    }
Ejemplo n.º 14
0
    // Start is called before the first frame update
    void Start()
    {
        levelLoader          = LevelLoader.instance;
        levelHelper          = LevelHelper.createLevelHelper(gameObject);
        midGroundTransformer = GetComponent <Transform>();
        time = levelHelper.time;

        loadMidGroundChunks();
    }
Ejemplo n.º 15
0
        /// <summary>
        /// 获取根据记录【指定ID】
        /// </summary>
        /// <param name="context"></param>

        public void get_follow_up(HttpContext context, string guid)
        {
            HttpRequest Request = context.Request;

            try
            {
                long   id             = RequestHelper.long_transfer(Request, "id");
                long   follow_cust_id = RequestHelper.long_transfer(Request, "follow_cust_id");
                long   follow_link_id = RequestHelper.long_transfer(Request, "follow_link_id");
                string follow_type    = RequestHelper.string_transfer(Request, "follow_type");
                //跟进列表
                List <follow_up> follow_selfs = dic_Self[guid];
                //指定的一个客户
                follow_up follow_up = (from t in follow_selfs
                                       where t.id == id
                                       select t).FirstOrDefault();
                Dictionary <string, object> dic_follow_up = ConverList <follow_up> .T_ToDic(follow_up);

                //联系人列表,当前用户
                List <cust_linkman> cust_linkman_selfs = cust_linkman_handle.dic_Self[guid];
                //联系人名称和客户名称
                cust_linkman cust_linkman = (from t in cust_linkman_selfs
                                             where t.id == follow_up.follow_link_id
                                             select t).FirstOrDefault();
                if (cust_linkman != null)
                {
                    dic_follow_up["follow_link_name"] = cust_linkman.link_name;
                    dic_follow_up["follow_cust_name"] = cust_linkman.link_cust_name;
                }
                //跟进类型
                dic_follow_up["follow_type_name"] = LevelHelper.Getfollow_level(follow_up.follow_type.ToString());
                if (Constant.list_picture_All != null)
                {
                    //获取指定的图片【类型 和ID】
                    List <picture> listp = (from t in Constant.list_picture_All
                                            where t.pic_en_table == "follow_up" && t.pic_table_id == id
                                            select t).ToList();
                    string pic = "";
                    foreach (picture p in listp)
                    {
                        pic += p.pic_url + ',';
                    }
                    dic_follow_up["pic"] = pic.Trim(',');
                }
                jsonModel = Constant.get_jsonmodel(0, "success", dic_follow_up);
            }
            catch (Exception ex)
            {
                jsonModel = Constant.ErrorGetData(ex);
            }
            finally
            {
                string jsonString = Constant.jss.Serialize(jsonModel);
                context.Response.Write("{\"result\":" + jsonString + "}");
            }
        }
Ejemplo n.º 16
0
    /// <summary>
    /// Callback to draw gizmos that are pickable and always drawn.
    /// </summary>
    void OnDrawGizmos()
    {
        CameraHelper cameraHelper = new CameraHelper(Camera.main);

        cameraHelper.DrawHelperInfos(Color.green);

        LevelHelper levelHelper = new LevelHelper(bottomLeftCorner, topRightCorner);

        levelHelper.DrawHelperInfos(Color.red);
    }
Ejemplo n.º 17
0
 public void Clicked()
 {
     if (levelProgressState >= LevelProgressState.Unlocked)
     {
         Scenes levelScene = LevelHelper.GetSceneOfLevelWithNumber(levelNumber);
         if (OnGoToScene != null)
         {
             OnGoToScene(levelScene);
         }
     }
 }
Ejemplo n.º 18
0
 public EnemyManager(
     Settings settings,
     EnemyFactory enemyFactory,
     LevelHelper level,
     [Inject(Id = "Spawner")] Transform spawnPoint
     )
 {
     _settings     = settings;
     _enemyFactory = enemyFactory;
     _level        = level;
     _spawnPoint   = spawnPoint;
 }
Ejemplo n.º 19
0
    float c_AngleInitialDisplace = 90; // because initial pos for line is upward, rather than aligned with X axis

    void Rotate(Orientation ori)
    {
        m_Orientation = ori;

        int dx = 0;
        int dy = 0;

        LevelHelper.OrientationToDirection(out dx, out dy, m_Orientation);

        float angle = Mathf.Atan2(dy, dx) * Mathf.Rad2Deg - c_AngleInitialDisplace;

        transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
    }
Ejemplo n.º 20
0
    public bool LinkLevelObject(LevelHelper link)
    {
        LevelObject = link;

        if (LevelObject == link)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Ejemplo n.º 21
0
    private void adjustVisibleLevelSize(ref LevelHelper levelHelper, CameraHelper cameraHelper)
    {
        if (levelHelper.width < cameraHelper.width)
        {
            levelHelper.right += cameraHelper.width - levelHelper.width;
        }
        if (levelHelper.height < cameraHelper.height)
        {
            levelHelper.top += cameraHelper.height - levelHelper.height;
        }

        topRightCorner.transform.position = new Vector3(levelHelper.right + 1, levelHelper.top + 1, topRightCorner.transform.position.z);
        GridManager.correctPositionToGrid(topRightCorner.transform);
        levelHelper = new LevelHelper(bottomLeftCorner, topRightCorner);
    }
Ejemplo n.º 22
0
    // Use this for initialization
    void Start()
    {
        _instance  = this;
        startPoint = GameObject.Find("StartPoint").transform;
        spawnPoint = GameObject.Find("SpawnPoint").transform;
        mainCamera = Camera.main;
        // 初始化
        LevelMesh.gameObject.SetActive(false);
        LevelHelper level = gameObject.GetComponent <LevelHelper>();

        levelName   = level.m_stringParams1.ToList <string>();
        rotateSpeed = level.m_floatParams1.ToList <float>();
        pinNum      = level.m_intParams1.ToList <int>();

        SpawnPin();
    }
Ejemplo n.º 23
0
        public MainWindow()
        {
            InitializeComponent();
            levelInfo                = LevelHelper.getLevelInfo(0);
            random                   = new Random();
            dispatcherTimer          = new DispatcherTimer();
            dispatcherTimer.Tick    += new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
            isGameContinue           = true;
            failNotiyer              = new FAIL(LevelHelper.gameLevel);

            dispatcherTimer.Start();
            // start init game info
            InitNode();
            setNodeStartLevel();
            refreshNodeState();
            // end of start game info

            object item = MainGrid.FindName("lableInfo");

            if (item is Label)
            {
                labelInfo = (Label)item;
            }
#if false
            object item = MainGrid.FindName("lable00");

            if (item is Label)
            {
                MessageBox.Show("find success!!");
                Label lbl = (Label)item;
                lbl.Background = new ImageBrush(new BitmapImage(new Uri(MASTER_PATH + pic15)));
                lbl.Background = null;
                lbl.Opacity    = 0.3;
            }

            ImageBrush imgBrush = new ImageBrush();

            imgBrush.ImageSource =
                new BitmapImage(new Uri(@"Dock.jpg", UriKind.Relative));
#endif


            string testDir = Directory.GetCurrentDirectory();
            //string[] test2 = Directory.GetDirectories("C:\\Users\\Toan\\source\\repos\\Duong\\Duong\\image\\");
        }
Ejemplo n.º 24
0
        protected override void Initialize()
        {
            Graphics = GraphicsDevice;

            ScreenWidth  = GraphicsDevice.PresentationParameters.Bounds.Width;
            ScreenHeight = GraphicsDevice.PresentationParameters.Bounds.Height;

            _paddle = new Paddle();
            _ball   = new Ball();

            _brickList = LevelHelper.GenerateLevel(5, 10);

            ScoreSystem.Score    = 0;
            ScoreSystem.Position = new Vector2(10, BrickBreaker.ScreenHeight - 30);

            base.Initialize();
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Initializes necessary components.
        /// </summary>
        static void InitializeGame()
        {
            Console.CursorVisible = false; // Ensure the cursor is invisible
            Console.Clear();               // Ensure there is nothing

            int level;

            do
            {
                Console.WriteLine("Level? (1 - 3)");
                string input = Console.ReadLine();
                int.TryParse(input, out level);
            }while (level == 0);

            Console.Clear();

            switch (level)
            {
            case 1:
                Walls = LevelHelper.LoadWalls(WallFormation.FourCrosses);
                break;

            case 2:
                Walls = LevelHelper.LoadWalls(WallFormation.Rectangle);
                break;

            case 3:
                Walls = LevelHelper.LoadWalls(WallFormation.FourCrosses | WallFormation.Rectangle);
                break;
            }

            ActiveSnake = new Snake(new Point(10, 10), 4); // Initialize
            ActiveCandy = new Candy();

            // Clear existing characters from the buffer
            while (Console.KeyAvailable)
            {
                Console.ReadKey(true);
            }

            // Initialize timer, subscribe and start
            SnakeTimer           = new Timer(100.0);
            SnakeTimer.Elapsed  += timer_Elapsed;
            SnakeTimer.AutoReset = false;
            SnakeTimer.Start();
        }
Ejemplo n.º 26
0
    // activate/inactivate objects pre nav mash generation
    static public void ActivateObjectsPreNavMeshGeneration(out List <GameObject> allObjectsActivated, out List <GameObject> allCreated,
                                                           out List <GameObject> allObjectsInactivated, out List <GameObject> zonesDeactivatedDuringNavMeshGeneration)
    {
        allObjectsActivated = FindAllObjectsToRenderDuringNavMeshGeneration();          // all permeable objects must be turned on before the scan
        foreach (GameObject it in allObjectsActivated)
        {
            it.SetActive(true);             // turn them all on
        }

        allCreated = CreateGameObjectsForNavMeshGeneration();

        zonesDeactivatedDuringNavMeshGeneration = new List <GameObject>();
        LevelHelper levelHelper = UnityEngine.GameObject.FindObjectOfType(typeof(LevelHelper)) as LevelHelper;

        if (null != levelHelper)
        {
            Transform zonesRoot = levelHelper.transform.Find(ZoneHelper.ZonesRootName);
            foreach (Transform singleZone in zonesRoot)
            {
                if (singleZone.gameObject.activeSelf && levelHelper.IsZoneExcludedFromNavMesh(singleZone.gameObject))
                {
                    zonesDeactivatedDuringNavMeshGeneration.Add(singleZone.gameObject);
                    singleZone.gameObject.SetActive(false);
                }
            }
        }

#if UNITY_EDITOR
        if (zonesDeactivatedDuringNavMeshGeneration.Count > 0)
        {
            string deactivatedZones = "";
            foreach (GameObject singleZone in zonesDeactivatedDuringNavMeshGeneration)
            {
                deactivatedZones += "\n-" + singleZone.gameObject.name;
            }
            UnityEditor.EditorUtility.DisplayDialog("Zones Deactivated During Nav Mesh Generation", "The following zones will not have nav mesh generated on them: \n" + deactivatedZones, "Ok");
        }
#endif

        allObjectsInactivated = FindAllObjectsToNOTRenderDuringNavMeshGeneration();
        foreach (GameObject it in allObjectsInactivated)
        {
            it.SetActive(false);
        }
    }
Ejemplo n.º 27
0
        void CreateNewCandyPoint()
        {
            Point suggestion;

            do
            {
                suggestion = LevelHelper.GetRandomPoint();
            }while (Program.ActiveSnake.Coordinates.Contains(suggestion) || Program.Walls.Any(x => x.Coordinates.Contains(suggestion)));

            if (Coordinates.Count == 1)
            {
                Coordinates[0] = suggestion;
            }
            else
            {
                Coordinates.Add(suggestion);
            }
            DrawHelper.Draw(Coordinates[0], RenderingChar);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EventHandler"/> class.
        /// </summary>
        /// <param name="client">
        /// The client.
        /// </param>
        /// <param name="homeService">
        /// The home Service.
        /// </param>
        /// <param name="config">
        /// The config.
        /// </param>
        /// <param name="service">
        /// The service.
        /// </param>
        /// <param name="levels">
        /// The levels.
        /// </param>
        /// <param name="channelHelper">
        /// The channel Helper.
        /// </param>
        /// <param name="commandService">
        /// The command service.
        /// </param>
        /// <param name="prefixService">
        /// The prefix Service.
        /// </param>
        public EventHandler(DiscordShardedClient client, TranslateLimitsNew limits, WaitService waits, DBLApiService dblService, TranslateMethodsNew translationMethods, TranslationService translationService, HomeService homeService, ConfigModel config, IServiceProvider service, LevelHelper levels, ChannelHelper channelHelper, CommandService commandService, PrefixService prefixService)
        {
            Client             = client;
            Config             = config;
            Provider           = service;
            CommandService     = commandService;
            prefixOverride     = DatabaseHandler.Settings.UsePrefixOverride;
            PrefixService      = prefixService;
            _ChannelHelper     = channelHelper;
            _LevelHelper       = levels;
            _HomeService       = homeService;
            _Translate         = translationService;
            Limits             = limits;
            Waits              = waits;
            TranslationMethods = translationMethods;
            DBLApi             = dblService;

            CancellationToken = new CancellationTokenSource();
        }
Ejemplo n.º 29
0
    // Start is called before the first frame update
    void Start()
    {
        rigidBody       = GetComponent <Rigidbody2D>();
        playerAnimation = GetComponent <Animator>();
        levelHelper     = LevelHelper.createLevelHelper(gameObject);

        beatsPerMinute     = levelHelper.songLoader.songData.track.tempo;
        secondsPerBeat     = 60f / beatsPerMinute;
        secondsPerHalfBeat = secondsPerBeat / 2f;

        inputQueue = new Queue <bool>(inputQueueSize);

        // Given fixed jump height, calculate gravity scale needed to fall from height in half a beat
        newAcceleration        = (2f * -jumpHeight) / Mathf.Pow(secondsPerHalfBeat, 2f);
        rigidBody.gravityScale = newAcceleration / Physics2D.gravity.y;

        // Using the new gravity scale, determine initial velocity needed to reach the fixed jump height in time
        jumpSpeedPrivate = (2 * jumpHeight) / secondsPerHalfBeat;
    }
Ejemplo n.º 30
0
    // Start is called before the first frame update
    void Start()
    {
        levelHelper = LevelHelper.createLevelHelper(gameObject);

        GameObject heartPoint = Instantiate(
            heartPointObject,
            new Vector3(
                0,
                0,
                0
                ),
            Quaternion.identity
            );

        float heartPointWidth  = heartPoint.GetComponent <Collider2D>().bounds.size.x;
        float heartPointHeight = heartPoint.GetComponent <Collider2D>().bounds.size.y;

        heartPoint.transform.position = new Vector2(
            -levelHelper.halfWidth + heartPointWidth,
            levelHelper.halfHeight - heartPointHeight
            );

        heartPointsStack = new Stack <GameObject>();
        heartPointsStack.Push(heartPoint);
        int addedHearts = 1;

        while (addedHearts < maxHealth)
        {
            GameObject newHeartPoint = Instantiate(
                heartPointObject,
                new Vector3(
                    -levelHelper.halfWidth + heartPointWidth + addedHearts,
                    levelHelper.halfHeight - heartPointHeight,
                    0
                    ),
                Quaternion.identity
                );

            heartPointsStack.Push(newHeartPoint);
            addedHearts++;
        }
    }