示例#1
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);
            GraphicsDevice.Viewport = gameView;

            spriteBatch.Begin(SpriteSortMode.Deferred,
                              BlendState.AlphaBlend,
                              SamplerState.PointClamp,
                              null,
                              null,
                              null,
                              Camera.Transform);

            switch (state)
            {
            case GameState.TitleScreen:
                break;

            case GameState.MainMenu:
                mainmenu.Draw(spriteBatch);
                break;

            case GameState.NewGame:
                newgame.Draw(spriteBatch);
                break;

            case GameState.Running:
                Tilemanager.Draw(spriteBatch);
                Playermanager.Draw(spriteBatch);
                break;

            case GameState.Paused:
                Tilemanager.Draw(spriteBatch);
                Playermanager.Draw(spriteBatch);
                pausemenu.Draw(spriteBatch);
                break;
            }
            //spriteBatch.DrawString(FpsFont, Convert.ToString(MaxTicks), new Vector2(750, 50), Color.White);

            spriteBatch.End();

            //
            GraphicsDevice.Viewport = sideHUD;
            spriteBatch.Begin();
            Texture2D rect = new Texture2D(graphics.GraphicsDevice, sideHUD.Width, sideHUD.Height);

            Color[] data = new Color[sideHUD.Width * sideHUD.Height];
            for (int i = 0; i < data.Length; ++i)
            {
                data[i] = Color.DarkGray;
            }
            rect.SetData(data);

            spriteBatch.Draw(rect, Vector2.Zero, Color.White);

            spriteBatch.End();

            base.Draw(gameTime);
        }
示例#2
0
 private void Awake()
 {
     gamemanager   = FindObjectOfType <Gamemanager>();
     playermanager = FindObjectOfType <Playermanager>();
     animator      = playermanager.GetComponent <Animator>();
     fademanager   = FindObjectOfType <Fademanager>(); // mapchage는 여러개라서 나중에 오류의 원인일수도
     DirSave       = new Queue <string>();
 }
示例#3
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
    }
示例#4
0
    public override bool CanBePickedUp()
    {
        Playermanager pm = Playermanager.ins;

        if (pm.CurrentHP < pm.MaxHP)
        {
            return(true);
        }
        else if (ignoreMaxHP)
        {
            return(true);
        }
        return(false);
    }
 //spawning and setting up components, called at the beginning of the scene
 protected void setComponents()
 {
     animator       = gameObject.GetComponent <Animator>();
     spriteRenderer = gameObject.GetComponent <SpriteRenderer>();
     rb2d           = gameObject.GetComponent <Rigidbody2D>();
     bc2d           = gameObject.GetComponent <BoxCollider2D>();
     setUpAudio();
     manager                  = GameObject.Find("/Overlay/UIManager");
     playermanager            = GameObject.Find("/Playermanager").GetComponent <Playermanager>();
     originDrag               = rb2d.drag;
     facingRight              = true;
     originGravity            = rb2d.gravityScale;
     InputManager.playerAlive = true;
 }
示例#6
0
    public override void Update()
    {
        if (lookDir != Vector3.zero && !strtSpd)
        {
            //  Debug.Log(";)");
            strtSpd     = true;
            rb.velocity = startSpeed * lookDir;
        }
//        else Debug.Log("No ;)");
        if (pm == null)
        {
            pm = Playermanager.ins;
        }
        if (playerObject == null)
        {
            playerObject = pm.playerObject;
        }
        else
        {
            Vector3 dirToPlayer = (playerObject.transform.position - transform.position).normalized;
            rb.velocity       += moveSpeed * Time.deltaTime * dirToPlayer;
            transform.position = new Vector3(transform.position.x, playerObject.transform.position.y, transform.position.z);
        }
    }
 private void Start()
 {
     pm = Playermanager.ins;
     DontDestroyOnLoad(gameObject);
 }
 void Awake()
 {
     instance = this;
 }
示例#9
0
 public override void Start()
 {
     base.Start();
     pm = Playermanager.ins;
 }
示例#10
0
 // Start is called before the first frame update
 void Start()
 {
     player        = GameObject.FindGameObjectWithTag("Player");
     getPlayerInfo = Playermanager.ins;
 }
示例#11
0
 private void Start()
 {
     pm            = Playermanager.ins;
     bookAnimatior = book.GetComponent <Animator>();
 }
示例#12
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)
        {
            TouchManager.Instance.Update(Camera);

            // Update camera position
            //Vector2 cameraMovement = Vector2.Zero;
            //position += cameraMovement/Camera.Zoom;

            switch (state)
            {
            case GameState.TitleScreen:
                break;

            case GameState.MainMenu:
                mainmenu.Update();
                Camera.Zoom = 1f;
                Camera.Update(Vector2.Zero, 64 * 32, 64 * 32);
                position = Camera.Position;
                break;

            case GameState.NewGame:

                newgame.Update(gameTime, this);
                Camera.Update(Vector2.Zero, 64 * 32, 64 * 32);
                position = Camera.Position;
                break;

            case GameState.LoadGame:
                //Tilemanager.LoadMap(mapname);
                Playermanager.Players[Playermanager.CurrentPlayerID].NewRound();
                Playermanager.Players[Playermanager.CurrentPlayerID].NewRound();
                state = GameState.Running;

                break;

            case GameState.SaveGame:
                Playermanager.SaveGame(SaveDir);

                break;

            case GameState.Running:
                Playermanager.Update(gameTime, this);
                Tilemanager.Update();
                Camera.Zoom = 2f;
                position   -= TouchManager.Instance.SwipeDirection / Camera.Zoom;
                Camera.Update(position,
                              Tilemanager.MapBounds.Width,
                              Tilemanager.MapBounds.Height);
                position = Camera.Position;
                //Camera.Update(GraphicsDevice.Viewport);

                /*if (Esc.IsKeyDown(Keys.Escape) == true)
                 * {
                 *  state = GameState.Paused;
                 * }
                 * if ((Playermanager.player[Playermanager.playing].end == true && Playermanager.player[Playermanager.playing].hud.newBool == false) || (Playermanager.player[Playermanager.notplaying].end == true && Playermanager.player[Playermanager.notplaying].hud.newBool == false))
                 * {
                 *  state = GameState.MainMenu;
                 *
                 * }*/

                break;


            case GameState.Paused:
                pausemenu.Update();

                break;

            case GameState.Exit:
                this.Exit();
                break;
            }

            // FPS räknare---------------------------------
            //if (tSec == DateTime.Now.Second)
            //{
            //    tTicks += 1;
            //}
            //else
            //{
            //    MaxTicks = tTicks;
            //    tTicks = 0;
            //    tSec = DateTime.Now.Second;
            //}
            //--------------------------------------------

            base.Update(gameTime);
        }
 private void Awake()
 {
     instance = this;
 }