public void Awake()
    {
        RIP Rip = new RIP();

        sprite = GetComponentInChildren <SpriteRenderer>();
        Rip    = Resources.Load <RIP>("RIP");
    }
Beispiel #2
0
    public void SpawnRIP(Panzee target, string lastWord)
    {
        GameObject obj = RIPPool.DequeueObjectPool();
        Vector2    pos = target.transform.position;

        obj.transform.position = pos;
        RIP rip = obj.GetComponent <RIP>();

        if (!lastWord.Equals(String.Empty))
        {
            rip.text.text = lastWord;
        }
        else
        {
            rip.text.text = target.text.text;
        }
        LayoutRebuilder.ForceRebuildLayoutImmediate(rip.textBubble);
        rip.textBubble.gameObject.SetActive(!rip.text.text.Equals(String.Empty));
        rip.nameText.text = target.name;
        RIPList.Add(rip);

        obj.SetActive(true);
    }
Beispiel #3
0
        private static WikiPerson GetPersonFromJsonElement(JsonElement item)
        {
            int id = 0;

            if (item.TryGetProperty("item", out JsonElement itemId))
            {
                int.TryParse(itemId.GetProperty("value").ToString().Substring(32), out id);
            }

            var name = String.Empty;

            if (item.TryGetProperty("itemLabel", out JsonElement itemLabel))
            {
                name = itemLabel.GetProperty("value").ToString();
            }

            var description = String.Empty;

            if (item.TryGetProperty("itemDescription", out JsonElement itemDescription))
            {
                description = itemDescription.GetProperty("value").ToString();
            }

            DateTime birthday = DateTime.MinValue;

            if (item.TryGetProperty("DR", out JsonElement DR))
            {
                DateTime.TryParse(DR.GetProperty("value").ToString(), out birthday);
            }

            DateTime death = DateTime.MinValue;

            if (item.TryGetProperty("RIP", out JsonElement RIP))
            {
                DateTime.TryParse(RIP.GetProperty("value").ToString(), out death);
            }

            var image = string.Empty;

            if (item.TryGetProperty("image", out JsonElement imageE))
            {
                image = imageE.GetProperty("value").ToString();
            }

            var link = String.Empty;

            if (item.TryGetProperty("article", out JsonElement article))
            {
                link = article.GetProperty("value").ToString();
            }


            var person = new WikiPerson
            {
                Id          = id,
                Name        = name,
                Description = description,
                Birthday    = birthday,
                Death       = death,
                Image       = image,
                Link        = link,
                //Rating = rating
            };

            return(person);
        }
 public void OnTriggerEnter2D(Collider2D collider)
 {
     RIP Rip = collider.GetComponent <RIP>();
 }
Beispiel #5
0
        public void Update(GameTime gameTime)
        {
            //Save the previous state of the keyboard and game pad so we can determine single key/button presses
            previousGamePadState  = currentGamePadState;  //Previous state becomes current state (GamePad)
            previousKeyboardState = currentKeyboardState; //Previous state becomes current state (Keyboard)

            //Read the current state of the keyboard and gamepad and store it
            currentGamePadState  = GamePad.GetState(PlayerIndex.One); //Get state of player ones gamepad
            currentKeyboardState = Keyboard.GetState();               //Get the state of the keyboard and store

            // Read the current state of the Mouse  and store it
            previousMouseState = currentMouseState; //Previous state becomes current state(Mouse)
            currentMouseState  = Mouse.GetState();  //Get state of mouse and store
            //Get Mouse State then Capture the Button type and Respond Button Press
            Vector2 mousePosition = new Vector2(currentMouseState.X, currentMouseState.Y);

            //Mouse moves to coordinates of point clicked onscreen


            //Get Thumbsticks Controls
            Position.X += currentGamePadState.ThumbSticks.Left.X * playerMoveSpeed; //Moves up and down at playerspeed
            Position.Y += currentGamePadState.ThumbSticks.Left.Y * playerMoveSpeed; //Moves left and right at playerspeed

            //Use the Keyboard/DPad
            //Checks if the left key or left button is being pressed
            if (currentKeyboardState.IsKeyDown(Keys.A) || currentGamePadState.DPad.Left == ButtonState.Pressed)
            {
                if (Position.X < 0) //If the x position goes beyond zero
                {
                    Position.X = 0; //Then reset the x position to zero
                }
                else //If the position is not beyond 0
                {
                    playerAnimation           = left;
                    Position.X               -= playerMoveSpeed; //Move the player left at a speed
                    playerAnimation.frameTime = 150;
                    playerState               = 1;
                }
            }

            //Checks if the right key or right button is being pressed
            else if (currentKeyboardState.IsKeyDown(Keys.D) || currentGamePadState.DPad.Right == ButtonState.Pressed)
            {
                if (Position.X > worldWidth) //If the x position goes beyond 750
                {
                    Position.X = worldWidth; //Reset the x position to 750
                }
                else //If the position is not beyond 750
                {
                    playerAnimation           = right;
                    Position.X               += playerMoveSpeed; //Move the player right at a speed
                    playerAnimation.frameTime = 150;
                    playerState               = 2;
                }
            }
            //Checks if the up key or up button is being pressed
            else if (currentKeyboardState.IsKeyDown(Keys.W) || currentGamePadState.DPad.Up == ButtonState.Pressed)
            {
                if (Position.Y < 0) //Checks if the y position goes beyond zero
                {
                    Position.Y = 0; //Reset the position to zero
                }
                else //If the y position is not beyond zero
                {
                    playerAnimation           = up;
                    Position.Y               -= playerMoveSpeed; //Move the player up at a speed
                    playerAnimation.frameTime = 150;
                    playerState               = 4;
                }
            }
            //Checks if the down key or button is being pressed
            else if (currentKeyboardState.IsKeyDown(Keys.S) || currentGamePadState.DPad.Down == ButtonState.Pressed)
            {
                if (Position.Y > worldHeight) //If the y position goes beyond 450
                {
                    Position.Y = worldHeight; //Reset the y position to 450
                }
                else //If the y position is not beyond 450
                {
                    playerAnimation           = down;
                    Position.Y               += playerMoveSpeed; //Move the player down at a speed
                    playerAnimation.frameTime = 150;
                    playerState               = 3;
                }
            }

            else if (currentKeyboardState == previousKeyboardState)
            {
                playerAnimation.sourceRectangle = new Rectangle(128, 0, 64, 64);
                playerAnimation.currentFrame    = 2;
                playerAnimation.frameTime       = 0;
            }

            //Checks if the left mouse button is being pressed
            if (currentMouseState.LeftButton == ButtonState.Pressed)
            {
                Vector2 posDelta = mousePosition - Position;
                posDelta.Normalize();
                posDelta = posDelta * playerMoveSpeed;
                Position = Position + posDelta;
            }
            //--------------------------------Player DEATH
            foreach (EnemyBullets L in EnemyBulletManager.bullets)
            {
                bulletRectangle = new Rectangle((int)L.Position.X, (int)L.Position.Y, L.Width, L.Height);
                PlayerRec       = new Rectangle((int)Position.X, (int)Position.Y, 64, 64);
                if (bulletRectangle.Intersects(PlayerRec))
                {
                    //dieing sound
                    //score
                    //enemy health
                    Health -= 5;
                    hurt.Play();

                    if (Health <= 0) //If the player health reaches zero
                    {
                        RIP.Play();
                        playerAnimation = dying; //The death animation is played
                        Active          = false; //The player becomes inactive
                    }

                    GUI.PlayerHealth = Health;

                    L.Active = false;
                }
            }
            //--------------------------------

            playerAnimation.Position = Position; //Updates the position via the player animation
            playerAnimation.Update(gameTime);    //Updates the playeranimation via gametime
        }