Example #1
0
    // Start is called before the first frame update
    void Start()
    {
        GM  = GetComponent <GhostManager>();
        PC  = GetComponent <PlayerController>();
        AC  = GetComponent <Animator>();
        HUD = GetComponent <HeadsUpDisplay>();
        CC  = GetComponent <CharacterController>();

        if (spawnAtCurrCoord)
        {
            spawnCoord = transform.position;
        }

        onDie              += OnDie;
        onWilt             += OnWilt;
        onSpawn            += OnSpawn;
        PC.onInteractStart += OnInteractStart;
        PC.onInteractEnd   += OnInteractEnd;
        PC.onInteractHold  += OnInteractHold;

        PC.onWilt += onWilt.Invoke;

        seeds         = new List <Seed>();
        onDirt        = false;
        currDirt      = null;
        isInteracting = false;
        //spawnCoord = transform.position;
        sunMeter     = 1f;
        waterMeter   = 1f;
        wiltMeter    = 1f;
        pressCounter = 0;
    }
Example #2
0
    private void Awake()
    {
        // Prepare levels here in GhostManager
        // Level 0
        GhostManager.AddLevel(4);
        levelSpawns.Add(new Vector3(0f, 0f, 0f));

        // Level 1
        GhostManager.AddLevel(2);
        levelSpawns.Add(new Vector3(0f, 0f, 0f));

        // Level 2
        GhostManager.AddLevel(3);
        levelSpawns.Add(new Vector3(0f, 0f, 0f));

        // Level 3
        GhostManager.AddLevel(2);
        levelSpawns.Add(new Vector3(0f, 0f, 0f));

        // Level 4
        GhostManager.AddLevel(2);
        levelSpawns.Add(new Vector3(0f, 0f, 0f));

        // Level 5
        GhostManager.AddLevel(4);
        levelSpawns.Add(new Vector3(0f, 0f, 0f));
    }
Example #3
0
    void GenerateMap(Map _mapToBeGenerated)
    {
        //Now taking tile data and adding appropriate objects to screen
        int numCheck;

        for (int i = 0; i < _mapToBeGenerated.tileValueList.Count; i++)
        {
            Vector2 objectSpawnPoint = MapHelper.ConvertToMapPoint(_mapToBeGenerated, i);
            if (int.TryParse(_mapToBeGenerated.tileValueList[i], out numCheck))              //if tile value is a number
            {
                if (numCheck != 0)
                {
                    //Loading generic block
                    GameObject tile;
                    tile = Instantiate(Resources.Load("Tiles/Block"), new Vector3(objectSpawnPoint.x, objectSpawnPoint.y, 0), Quaternion.identity) as GameObject;
                    //Adjusting collider
                    tile.GetComponent <BoxCollider2D>().size = new Vector2((float)_mapToBeGenerated.tileWidth / 100, (float)_mapToBeGenerated.tileHeight / 100);
                    //Applying appropriate sprite to it
                    tile.GetComponent <SpriteRenderer>().sprite = tileSpriteArr[MapHelper.ConvertToInt(_mapToBeGenerated.tileValueList[i])];
                    //Additional settings for each block
                    switch (_mapToBeGenerated.tileValueList[i])
                    {
                    case "2":
                        tile.tag = "bombblock";
                        break;

                    case "3":
                        tile.layer = LayerMask.NameToLayer("Ground-2");
                        break;
                    }
                }
            }
            else               //if a tile value is any other value besides a number
            {
                if (_mapToBeGenerated.tileValueList[i] != "G")
                {
                    GameObject spawnGuy;
                    //Suppose we have the value "P1".
                    //"characterValue" holds the first character of this string value, and it denotes the type of
                    //character it is. In this case, 'P' signifies Ghost.
                    //"otherValue" hold the second character of the string value, and it denotes any other info
                    //the character needs to have. In this example, the '1' in "P1" signifies this ghost is Player One.
                    string characterValue = _mapToBeGenerated.tileValueList[i][0].ToString();
                    string otherValue     = (_mapToBeGenerated.tileValueList[i].Length > 1) ? _mapToBeGenerated.tileValueList[i][1].ToString() : "";
                    spawnGuy = Instantiate(guyArr[System.Array.IndexOf(guyNameArr, characterValue)], new Vector3(objectSpawnPoint.x, objectSpawnPoint.y, 0), Quaternion.identity) as GameObject;
                    if (characterValue == "P")
                    {
                        GhostManager.SetGhost(ref spawnGuy, MapHelper.ConvertToInt(otherValue));
                        Camera.main.transform.parent   = spawnGuy.transform;
                        Camera.main.transform.position = new Vector3(spawnGuy.transform.position.x, spawnGuy.transform.position.y, -10);
                    }
                }
                else
                {
                    GameObject goalObject;
                    goalObject = Instantiate(Resources.Load <GameObject>("Objects/goal/Goal"), new Vector3(objectSpawnPoint.x, objectSpawnPoint.y, 0), Quaternion.identity) as GameObject;
                }
            }
        }
    }
Example #4
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            KeyboardState keyboardState = Keyboard.GetState();

            // Update Pacman position and check for collisions with map elements
            PacmanObject.Update(keyboardState);

            // Update Ghosts position and checks for collisions with pacman
            GhostManager.Update(gameTime);

            // Check for collisions with pacman
            GhostManager.CheckForCollisions(PacmanObject.CurrentTile, out pacmanKilled);
            if (pacmanKilled)
            {
                LoadContent();
            }

            base.Update(gameTime);
        }
Example #5
0
 public static void LoadLevel(int level)
 {
     levelIndex = level;
     PlayerController.RobotIndex = 0;
     GhostManager.ClearGhostData(level);
     RestartLevelWithGhosts();
 }
Example #6
0
 private void OnDestroy()
 {
     if (Instance == this)
     {
         Instance = null;
     }
 }
Example #7
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            PerformFixedUpdates();
            UpdateOncePerFrame();

            renderer.Requested.Camera   = sceneManager.Camera;
            renderer.Requested.Viewport = windowViewport;

            renderer.PartialGLStateResetToDefaults();

            renderer.RenderCurrentClear();

            GL.Viewport(
                renderer.Requested.Viewport.X,
                renderer.Requested.Viewport.Y,
                renderer.Requested.Viewport.Width,
                renderer.Requested.Viewport.Height
                );
            GL.Enable(EnableCap.CullFace);
            GL.FrontFace(FrontFaceDirection.Ccw);

            renderer.CurrentGroup = sceneManager.RenderGroup;
            renderer.RenderGroup();

            Render2D();

            SwapBuffers();

            GhostManager.Process();

            RenderStack.Graphics.Debug.FrameTerminator();
        }
 private void InitializeComponents()
 {
     UI              = FindObjectOfType <UIManager>();
     _timer          = gameObject.AddComponent <GameTimer>();
     _ghostManager   = new GhostManager(_ghosts);
     _frightenedMode = new FrightenedMode(_ghostManager, _timer);
 }
Example #9
0
    // Start is called before the first frame update
    void Start()
    {
        PS    = GetComponent <PlayerState>();
        GM    = GetComponent <GhostManager>();
        PPV   = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <PostProcessVolume>();
        texts = new Dictionary <string, Text>();
        List <Text> children = new List <Text>(GameObject.Find("HUD").GetComponentsInChildren <Text>());

        promptTextStack = new Stack <string>();
        promptTextStack.Push(" ");
        foreach (Text t in children)
        {
            texts.Add(t.name, t);
            Debug.Log("HUD::Added: " + t.name);
        }
        //sunBar = GameObject.Find("SunBarForeground").GetComponent<Image>();
        //waterBar = GameObject.Find("WaterBarForeground").GetComponent<Image>();
        wiltBar       = GameObject.Find("WiltBarForeground").GetComponent <Image>();
        wiltText      = texts["WiltText"];
        wiltBarColor  = wiltBar.color;
        wiltTextColor = wiltText.color;

        HideWiltBar();
        warningResetTime = Time.time;
    }
Example #10
0
        void Application_Unload(object sender, EventArgs e)
        {
#if false
            GhostManager.Process();
#if DEBUG
            GhostManager.CheckAllDeleted();
#endif
#endif
        }
Example #11
0
        protected void Render()
        {
            var updateManager = RenderStack.Services.BaseServices.Get <UpdateManager>();

            GhostManager.Process();
            updateManager.UpdateOncePerFrame();
            GhostManager.Process();
#if false
            var statistics = Services.Get <Statistics>();
            if (statistics != null)
            {
                statistics.Update();
            }
#endif

            GhostManager.Process();

            var highLevelRenderer = RenderStack.Services.BaseServices.Get <HighLevelRenderer>();
#if CATCH
            try
#endif
            {
                highLevelRenderer.Render();
            }
#if CATCH
            catch (OpenTK.GraphicsException e)
            {
                Trace.TraceError("Caught GraphicsException");
                Trace.TraceError("OpenGL error:\n" + e.ToString());
                StopMessage(
                    "OpenGL error has occured.\n"
                    + "Please report this to [email protected]\n"
                    + "You can press CTRL-C to copy text from this window.\n"
                    + "Thank you.\n\n"
                    + e.ToString(),
                    "RenderStack - OpenGL Error"
                    );
                Close();
            }
            catch (System.Exception e)
            {
                Trace.TraceError("Caught Exception");
                Trace.TraceError("OpenGL error:\n" + e.ToString());
                StopMessage(
                    "Error has occured.\n"
                    + "Please report this to [email protected]\n"
                    + "You can press CTRL-C to copy text from this window.\n"
                    + "Thank you.\n\n"
                    + e.ToString(),
                    "RenderStack - Generic Error"
                    );
                Close();
            }
#endif

            GhostManager.Process();
        }
Example #12
0
 private void Awake()
 {
     if (Instance)
     {
         Destroy(gameObject);
     }
     else
     {
         Instance = this;
     }
 }
Example #13
0
 void FixedUpdate()
 {
     if (GameManager.gameState == GameState.Running)
     {
         bool res = GhostManager.GetNextPosition(out readPos, out readRot);
         if (!res)
         {
             Destroy(gameObject);
         }
     }
 }
Example #14
0
 // Use this for initialization
 private void Awake()
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
     }
 }
Example #15
0
    // Use this for initialization
    void Start()
    {
        _anima        = GetComponent <Animator>();
        _rigidbody    = GetComponent <Rigidbody2D>();
        _audioManager = GetComponent <AudioManager>();
        _manager      = GetComponent <GhostManager>();

        _fsm = new MyFSM(Moves);

        _fsm.AddStates((int)GhostState.Attack, DoAttack);
    }
Example #16
0
    private void Awake()
    {
        if (instance != null)
        {
            Destroy(instance.gameObject);
        }
        instance = this;

        fixedGhosts   = new Dictionary <int, Ghost>();
        moveInGhosts  = new Dictionary <int, Ghost>();
        moveOutGhosts = new Dictionary <int, Ghost>();
    }
Example #17
0
    public void NextLevel()
    {
        timeText.gameObject.SetActive(true);
        timeText2.gameObject.SetActive(false);
        skipButton.gameObject.SetActive(true);
        nextButton.gameObject.SetActive(false);

        timer.Reset();
        //GameObject.FindGameObjectWithTag("Player").transform.GetChild(1).gameObject.SetActive(false);
        GhostManager.CleanHistory();
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
    }
Example #18
0
    public void SelectTimeline()
    {
        // Save Current Timeline
        GhostManager.SetGhostData(PlayerController.RobotIndex, PlayerController.GetRecordedMovement());

        // Enable Timeline Panel
        chooseTimelineScreen = Resources.FindObjectsOfTypeAll <ChooseTimelineScreen>()[0].gameObject;
        chooseTimelineScreen.SetActive(true);

        // Disable Pause Panel
        ps.DisablePausePanel();
    }
Example #19
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
         StartCoroutine(CR_GetPaths());
         StartCoroutine(CR_PlaybackGhosts());
     }
     else
     {
         Destroy(gameObject);
     }
 }
Example #20
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        for (int i = 0; i < transform.childCount; i++)
        {
            GameObject ghost = transform.GetChild(i).gameObject;
            ghostList.Add(ghost);
            ghostScriptList.Add(ghost.GetComponent <Ghost>());
        }
    }
Example #21
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Player"))
     {
         PS = other.gameObject.GetComponent <PlayerState>();
         GM = other.gameObject.GetComponent <GhostManager>();
         if (!GM.isRecording)
         {
             Debug.Log("CheckPoint::New Spawn Coord: " + this.spawnCoord.ToString());
             PS.spawnCoord = spawnCoord;
             PS.spawnRot   = spawnRot;
         }
     }
 }
Example #22
0
    public void Quit()
    {
        // Reset level data
        GhostManager.ClearGhostData();

        // Unpause
        ps.UnpauseGame();

        // Disable Pause Panel
        ps.DisablePausePanel();

        // Load mainmenu scene
        print("Main Menu scene transition");
        SceneManager.LoadScene(0);
    }
Example #23
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend,
                              null, null, null, null, WindowScale);

            MapObject.Draw(spriteBatch);
            ScoreBoardObject.Draw(spriteBatch);
            PacmanObject.Draw(spriteBatch, gameTime);
            GhostManager.Draw(spriteBatch, gameTime);

            spriteBatch.End();

            base.Draw(gameTime);
        }
Example #24
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Player"))
     {
         //TODO: Prompt player that they can modify the ghost in seed
         PS  = other.GetComponent <PlayerState>();
         HUD = other.GetComponent <HeadsUpDisplay>();
         GM  = other.GetComponent <GhostManager>();
         if (!GM.isRecording)
         {
             Debug.Log("Seed::Player touching seed");
             HUD.PushPrompt(PromptText);
             PS.onInteractEnd += OnInteract;
             PS.onSeed         = true;
         }
     }
 }
Example #25
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Flag that causes the game to restart
            pacmanKilled = false;

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // Initialize and load map and scoreboard
            MapObject.LoadContent(Content);
            ScoreBoardObject.LoadContent(Content);

            // Load pacman and set starting position
            PacmanObject.LoadContent(Content, MapObject.GetTile('S'));

            // Initialize the ghosts
            GhostManager.LoadContent(Content);
        }
Example #26
0
        private void Application_Unload(object sender, EventArgs e)
        {
            render = false;
            if (Configuration.threadedRendering && renderThread != null)
            {
                renderThread.Join();
                renderThread = null;
            }
            Context.MakeCurrent(WindowInfo);
            IRenderer renderer = RenderStack.Services.BaseServices.Get <IRenderer>();

            if (renderer != null)
            {
                renderer.Unload();
            }
            GC.Collect();
            GhostManager.Process();
        }
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            input   = new InputHandler(this);
            console = new GameConsole(this);

            this.Components.Add(input);
            this.Components.Add(console);

            pac = new PacMan.MonogamePacMan(this);
            this.Components.Add(pac);



            ghostManager = new GhostManager(this, pac);
            this.Components.Add(ghostManager);
        }
Example #28
0
 private void OnTriggerEnter(Collider collider)
 {
     if (collider.CompareTag("Player"))
     {
         Debug.Log("Dirt::Player stepped on dirt");
         PS                 = collider.gameObject.GetComponent <PlayerState>();
         GM                 = collider.gameObject.GetComponent <GhostManager>();
         HUD                = collider.gameObject.GetComponent <HeadsUpDisplay>();
         PS.onDirt          = true;
         PS.onInteractEnd  += PlantSeed;
         PS.onInteractHold += ResetDirt;
         if (!GM.isRecording)
         {
             HUD.PushPrompt(PromptText);
             PS.currDirt = this;
             GM.duration = _ghostDuration;
         }
         isTracking = true;
         Text.gameObject.SetActive(true);
     }
 }
Example #29
0
    void LeaveCharacter(bool _disableAsWell)
    {
        //Later we will check which player activated this command. For now, let's set to player 1
        GameObject     ghostInControl = GhostManager.GetGhost(1);
        GhostBehaviour ghostScript    = ghostInControl.GetComponent <GhostBehaviour>(); //save a reference to his script

        ghostInControl.transform.position = transform.position;                         //set ghost to where possessed enemy was
        ghostScript.StopMoving();                                                       //stop character's velocity
        Camera.main.transform.parent = ghostInControl.transform;                        //set camera's parent back to ghost
        ghostInControl.layer         = frontLayer;                                      //send ghost to front layer if he isn't already
        if (ghostInControl.transform.localScale.x > 0 && transform.localScale.x < 0 ||
            ghostInControl.transform.localScale.x < 0 && transform.localScale.x > 0)    //if player is facing the other direction from ghost
        {
            ghostScript.FlipSprite();                                                   //flip ghost sprite
        }
        ghostInControl.renderer.enabled = true;                                         //set his renderer back on so he can be seen
        ghostScript.controlState        = ControlState.PlayerControlled;                //player can control the ghost again
        Destroy(gameObject);                                                            //ghost kills the character he possessed when he's done
        if (_disableAsWell)                                                             //if the disable as well boolean is set to true
        {
            ghostScript.controlState = ControlState.Disabled;                           //disable the ghost. this is ideal for when he reaches the goal
        }
    }
Example #30
0
    private void SetupManagers()
    {
        // create ghost manager
        if (RaceSettings.gamemode == E_GAMEMODES.TimeTrial)
        {
            ghostManager = gameObject.AddComponent<GhostManager>();
            ghostManager.r = RaceSettings.SHIPS[0];
        }

        // hide mouse cursor
        Cursor.visible = false;

        // create music manager
        if (musicManagerEnabled)
        {
            GameObject newObj = new GameObject("Music Manager");
            musicManager = newObj.AddComponent<MusicManager>();
            musicManager.r = RaceSettings.SHIPS[0];
        }
    }
Example #31
0
 // Use this for initialization
 void Start()
 {
     GhostManager.GetStartPosition(out readPos, out readRot);
     transform.position = readPos;
     transform.rotation = readRot;
 }
	/**
	 * 
	 */
	void Awake()
	{
		mInstance = this;
	}