Beispiel #1
0
        public override void LoadContent()
        {
            base.LoadContent();
            timer   = 0;
            player  = new Player(new Rectangle(600, 500, 50, 50));
            player2 = new Player(new Rectangle(800, 800, 50, 50));

            Platform  platform  = new Platform("Platform", new Rectangle(700, 800, 100, 30));
            Platform  platform2 = new Platform("Platform", new Rectangle(600, 900, 100, 30));
            Platform  platform3 = new Platform("Platform", new Rectangle(550, 700, 100, 30));
            Platform  platform4 = new Platform("Platform", new Rectangle(0, 950, 10000, 30));
            Platform  platform5 = new Platform("Platform", new Rectangle(1000, 400, 30, 600));
            Spike     spike     = new Spike("Spike", new Rectangle(900, 900, 30, 100));
            BouncePad bouncePad = new BouncePad("BouncePad", new Rectangle(200, 950, 60, 10));
            Pillow    pillow    = new Pillow("Pillow", new Rectangle(300, 920, 30, 20));

            sprites.Add(platform);
            sprites.Add(platform2);
            sprites.Add(platform3);
            sprites.Add(platform4);
            sprites.Add(platform5);
            sprites.Add(player2);
            sprites.Add(player);
            sprites.Add(spike);
            sprites.Add(bouncePad);
            sprites.Add(pillow);

            foreach (var s in sprites)
            {
                s.LoadContent(Content);
            }
            controller  = new GameController(1);
            controller2 = new GameController(2);
        }
Beispiel #2
0
 void ThrowAttack(Pillow p)
 {
     Debug.Log("BLAMO!!");
     //pillow is 'dropped' when thrown
     p.isThrown = true;
     DropPillow(p);
 }
Beispiel #3
0
        public async Task <IActionResult> Create(Pillow pillow, IFormFile image)
        {
            if (image != null)
            {
                var path = FilesHelper.UploadFile(_appEnvironment.WebRootPath + "\\Images\\Pillows\\", image);
                pillow.ImageName = path.ToString();
            }
            if (ModelState.IsValid)
            {
                pillow.Id = Guid.NewGuid();
                //pillow.Category = Category.Pillows;
                //Size size = new Size
                //{
                //    Id = Guid.NewGuid(),
                //    Height = pillow.Size.Height,
                //    Width = pillow.Size.Width
                //};
                //_context.Add(pillow);
                //pillow.SizeId = size.Id;
                _context.Add(pillow);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(RedirectToAction(nameof(Index)));
        }
Beispiel #4
0
    private void SpawnPillow()
    {
        _currentPillow = Instantiate(PillowObject, transform.position, PillowObject.transform.rotation) as Pillow;

        Vector3 rot = _currentPillow.transform.eulerAngles;

        rot.y = transform.eulerAngles.y - 90f;

        _currentPillow.transform.eulerAngles = rot;

        Vector3 pos = new Vector3();

        if (Mathf.Approximately(transform.eulerAngles.y, 0f))
        {
            pos = RelativePosition;
        }
        else if (Mathf.Approximately(transform.eulerAngles.y, 90f))
        {
            pos = new Vector3(-RelativePosition.z, RelativePosition.y, -RelativePosition.x);
        }
        else if (Mathf.Approximately(transform.eulerAngles.y, 180f))
        {
            pos = new Vector3(-RelativePosition.x, RelativePosition.y, -RelativePosition.z);
        }
        else if (Mathf.Approximately(transform.eulerAngles.y, 270f))
        {
            pos = new Vector3(RelativePosition.z, RelativePosition.y, RelativePosition.x);
        }

        _currentPillow.transform.position += pos;
    }
Beispiel #5
0
    void OnTriggerExit(Collider other)
    {
        if (other.tag == "Pillow")
        {
            Pillow pillow = other.GetComponent <Pillow>();

            if (Pillows.Contains(pillow))
            {
                Pillows.Remove(pillow); // Deregister the pillow
            }
        }
    }
Beispiel #6
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Pillow")
        {
            Pillow pillow = other.GetComponent <Pillow>();

            if (pillow.currentState == PillowState.Idle)
            {
                Pillows.Add(pillow); // Register the pillow
            }
        }

        //if (other.tag == "Punch")
        //    other.transform.parent.parent.parent.parent.GetComponent<Player>().Score -= 10;
    }
 public Main()
 {
     //equips
     summonbox = new BrokenPrinter();
     reactor   = new UnstableQuantumReactor();
     lum       = new Lumpkin();
     //items
     grinder = new Item();
     key     = new BrokenKeycard();
     nokia   = new Nokia();
     root    = new Root();
     trinket = new MechanicalTrinket();
     pillow  = new Pillow();
     sundial = new Sundial();
     scp     = new SCP();
 }
Beispiel #8
0
 private void interact(Entity entity, List <Entity> sprites)
 {
     foreach (Entity s in sprites)
     {
         if (s is Pillow)
         {
             List <Entity> pillow = new List <Entity>();
             pillow.Add(s);
             if (!CheckRightCollision(entity, pillow) || !CheckLeftCollision(entity, pillow))
             {
                 //entity.PlayJumpSound();
                 Pillow p = (Pillow)s;
                 p.holding = true;
             }
         }
     }
 }
Beispiel #9
0
    void Update()
    {
        if (_currentPillow == null)
        {
            _elapsedTime += Time.deltaTime;

            if (_elapsedTime >= _nextSpawnDelay)
            {
                _elapsedTime = 0f;
                SpawnPillow();
                _nextSpawnDelay = GetNextSpawnDelay();
            }
        }
        else if (_currentPillow.IsOwned)
        {
            _currentPillow = null;
            _elapsedTime   = 0f;
        }
    }
Beispiel #10
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Pillow")
        {
            Pillow incomingPillow = other.GetComponent <Pillow>();

            // getting hit by a pillow
            if (incomingPillow.IsThrown)
            {
                Debug.Log("abc");
                if (incomingPillow.Owner != this)
                {
                    //player is hit
                    Debug.Log("Child is hit by a pillow");

                    if (!ReceiveSound.isPlaying)
                    {
                        ReceiveSound.Play();
                    }

                    Push(other.GetComponent <Rigidbody>().velocity.normalized * 10 * hitPushBackForce);
                    Destroy(other.gameObject);
                }
            }
            // picking up a pillow
            else if (this.pillow == null && incomingPillow.IsPickable)
            {
                //Debug.Log("def");
                pillow = incomingPillow;

                pillow.transform.parent = transform;                  // make the pillow a child of Child
                pillow.gameObject.SetActive(false);
                pillow.GetComponent <Rigidbody>().isKinematic = true; // dont make pillow obey to gravity when in a child's hands
                pillow.IsOwned = true;
                pillow.Owner   = this;
                AnimationPillow.SetActive(true);

                // TODO: place the pillow correctly or animate or something...
            }
        }
    }
Beispiel #11
0
    public void PickUp()
    {
        if (Pillows.Count > 0)
        {
#if UNITY_EDITOR
            Debug.Log(LogUtility.MakeLogString("Player", name + " picked up a pillow."));
#endif

            top.SetInteger("CurrentState", 2);
            StartCoroutine(PickFinish());

            Pillow pillow = Pillows[0];
            if (Ammo.Contains(Pillows[0]))
            {
                // no valid to add, find others
                pillow = null;
                if (Pillows.Count >= 2)
                {
                    for (int i = 0; i < Pillows.Count; i++)
                    {
                        if (!Ammo.Contains(Pillows[i]))
                        {
                            pillow = Pillows[i];
                        }
                    }
                }
            }
            if (pillow)
            {
                pillow.transform.parent        = NumPillowsHeld++ == 0 ? SlotLA : SlotRA;
                pillow.transform.localPosition = Vector3.zero;
                pillow.transform.localRotation = Quaternion.identity;
                pillow.Pick(this);
                AudioManager.Instance.PlaySoundEffect("PillowNearFight1", false);
                Ammo.Enqueue(pillow);
            }
        }
    }
Beispiel #12
0
        public override void Update(GameTime gameTime)
        {
            controller.Update(player, gameTime, sprites);
            controller2.Update(player2, gameTime, sprites);

            player.Update(ScreenManager.Instance.Dimensions, gameTime, Content);

            foreach (Entity s in sprites)
            {
                if (s is Pillow)
                {
                    Pillow p = (Pillow)s;
                    if (p.holding)
                    {
                        Rectangle playerHolding = new Rectangle(player.SpritePosition.X, player.SpritePosition.Y, 30, 20);
                        playerHolding.Offset(-30, 0);
                        s.SpritePosition = playerHolding;
                    }
                }
            }

            if (timer > 0)
            {
                timer -= gameTime.ElapsedGameTime.TotalSeconds;
            }
            else if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                LevelScreen s = this;
                ScreenManager.Instance.ChangeScreen(new PauseScreen(s), true);
                timer = 0.2;
            }

            if (player.health <= 0 || player2.health <= 0)
            {
                ScreenManager.Instance.ChangeScreen(new DeathScreen(), true);
            }
        }
Beispiel #13
0
    public void ThrowMecanimPillow()
    {
        if (pillow == null)
        {
            return;
        }

        Transform target = _autoTarget.GetTarget(transform.forward);

        Vector3 direction;

        if (target != null)
        {
            direction = target.transform.position - pillow.transform.position;
        }
        else
        {
            direction = transform.forward;
        }

        direction = direction.normalized;

        pillow.gameObject.SetActive(true);
        pillow.transform.localPosition    = new Vector3(0.109f, -0.407f, 0.389f);
        pillow.transform.localEulerAngles = new Vector3(0f, 204.46f, 310.0002f);

        AnimationPillow.SetActive(false);

        pillow.Throw(direction * ThrowForce);

        pillow.IsOwned = false;

        target = null;

        pillow = null;
    }
Beispiel #14
0
    private void HandleActionPress()
    {
        if (!Input.GetButtonDown(_commandMap[Commands.Fire]))
        {
            return;
        }

        if (!_pillow)
        {
            // ReSharper disable once Unity.PreferNonAllocApi
            var results = Physics.OverlapSphere(transform.position, 1, throwable);
            if (!(results?.Length > 0))
            {
                return;
            }
            foreach (var result in results)
            {
                var temPillow = result.transform.GetComponent <Pillow>();
                if (temPillow.heldBy != null)
                {
                    continue;
                }
                _pillow = temPillow;
                _pillow.AttachToPlayer(handTransform, this);
                animator.SetBool("RunGrab", true);
                return;
            }
        }
        else
        {
            _pillow.Throw(playerNumber == 1 ? transform.forward : transform.forward * -1);
            _pillow = null;
            animator.SetBool("RunGrab", false);
            _audioSource.PlayOneShot(throwClips[UnityEngine.Random.Range(0, throwClips.Length)]);
        }
    }
Beispiel #15
0
        public async Task <IActionResult> Edit(Pillow pillow, IFormFile image)
        {
            if (image != null)
            {
                string fileName = pillow.ImageName;
                string fullPath = _appEnvironment.ApplicationName + "\\Images\\Pillows\\" + pillow.ImageName;
                if (System.IO.File.Exists(fullPath))
                {
                    System.IO.File.Delete(fullPath);
                }
                var path = FilesHelper.UploadFile(_appEnvironment.WebRootPath + "\\Images\\Pillows\\", image);
                pillow.ImageName = path.ToString();
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pillow);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PillowsExists(pillow.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(pillow));
        }
Beispiel #16
0
    void Update()
    {
        if (_currentPillow == null)
        {
            _elapsedTime += Time.deltaTime;

            if (_elapsedTime >= _nextSpawnDelay)
            {
                _elapsedTime = 0f;
                SpawnPillow();
                _nextSpawnDelay = GetNextSpawnDelay();
            }
        }
        else if (_currentPillow.IsOwned)
        {
            _currentPillow = null;
            _elapsedTime = 0f;
        }
    }
Beispiel #17
0
    public void ThrowMecanimPillow()
    {
        if (pillow == null) return;

        Transform target = _autoTarget.GetTarget(transform.forward);

        Vector3 direction;

        if (target != null)
        {
            direction = target.transform.position - pillow.transform.position;
        }
        else
        {
            direction = transform.forward;
        }

        direction = direction.normalized;

        pillow.gameObject.SetActive(true);
        pillow.transform.localPosition = new Vector3(0.109f, -0.407f, 0.389f);
        pillow.transform.localEulerAngles = new Vector3(0f, 204.46f, 310.0002f);

        AnimationPillow.SetActive(false);

        pillow.Throw(direction * ThrowForce);

        pillow.IsOwned = false;

        target = null;

        pillow = null;
    }
Beispiel #18
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Pillow"){

            Pillow incomingPillow = other.GetComponent<Pillow>();

            // getting hit by a pillow
            if (incomingPillow.IsThrown) {
                Debug.Log("abc");
                if (incomingPillow.Owner != this)
                {
                    //player is hit
                    Debug.Log("Child is hit by a pillow");

                    if (!ReceiveSound.isPlaying)
                    {
                        ReceiveSound.Play();
                    }

                    Push(other.GetComponent<Rigidbody>().velocity.normalized * 10 * hitPushBackForce);
                    Destroy(other.gameObject);
                }
            }
            // picking up a pillow
            else if (this.pillow == null && incomingPillow.IsPickable) {
                //Debug.Log("def");
                pillow = incomingPillow;

                pillow.transform.parent = transform; // make the pillow a child of Child
                pillow.gameObject.SetActive(false);
                pillow.GetComponent<Rigidbody>().isKinematic = true; // dont make pillow obey to gravity when in a child's hands
                pillow.IsOwned = true;
                pillow.Owner = this;
                AnimationPillow.SetActive(true);

                // TODO: place the pillow correctly or animate or something...
            }
        }
    }
Beispiel #19
0
 //Attack functions
 //A pillow needs to be picked up before any attack works
 void PickupPillow(Pillow p)
 {
     heldPillows.Add(p);
     p.PickedUp(this);
 }
Beispiel #20
0
 void DropPillow(Pillow p)
 {
     p.Drop();
     heldPillows.RemoveAt(0);
 }
Beispiel #21
0
    private void SpawnPillow()
    {
        _currentPillow = Instantiate(PillowObject, transform.position, PillowObject.transform.rotation) as Pillow;

        Vector3 rot = _currentPillow.transform.eulerAngles;
        rot.y = transform.eulerAngles.y - 90f;

        _currentPillow.transform.eulerAngles = rot;

        Vector3 pos = new Vector3();

        if (Mathf.Approximately(transform.eulerAngles.y, 0f))
        {
            pos = RelativePosition;
        }
        else if (Mathf.Approximately(transform.eulerAngles.y, 90f))
        {
            pos = new Vector3(-RelativePosition.z, RelativePosition.y, -RelativePosition.x);
        }
        else if (Mathf.Approximately(transform.eulerAngles.y, 180f))
        {
            pos = new Vector3(-RelativePosition.x, RelativePosition.y, -RelativePosition.z);
        }
        else if (Mathf.Approximately(transform.eulerAngles.y, 270f))
        {
            pos = new Vector3(RelativePosition.z, RelativePosition.y, RelativePosition.x);
        }

        _currentPillow.transform.position += pos;
    }
Beispiel #22
0
    void FixedUpdate()
    {
        if (!isPushedBack)
        {
            // Picking up pillows
            if (Input.GetAxis("Pick" + ControllerId) == 0)
            {
                isSubmitButtonUp = true;
            }
            else if (isSubmitButtonUp)
            {
                isSubmitButtonUp = false;

                if (NumPillowsHeld >= 2) // exceed the number that one player can hold
                {
                    Drop();
                }
                else
                {
                    PickUp();
                }
            }

            //Attack
            if (Input.GetAxis("Attack" + ControllerId) == 0)
            {
                isAttackButtonUp = true;
            }
            else if (isAttackButtonUp)
            {
                isAttackButtonUp = false;

                top.SetInteger("CurrentState", 4);
                StartCoroutine(AttackFinish());

                if (numPillowHold == 0)
                {
                    // that is a punch
                    SlotLA.GetComponent <SphereCollider>().enabled = true;
                }
                else
                {
                    // a Pillow Sweep
                    if (numPillowHold == 1)
                    {
                        AudioManager.Instance.PlaySoundEffect("PillowNearFight", false);
                        var temp = Ammo.Peek();
                        temp.Attack();
                    }
                }
            }

            // Tossing pillows
            if (Input.GetAxis("Toss" + ControllerId) == 0)
            {
                if (!isCancelButtonUp && NumPillowsHeld > 0)
                {
                    Pillow pillow = Ammo.Dequeue();
                    pillow.Throw(model.transform.forward, model.transform.up, (emPower - 0.08f + 1) * powerThrowForward, (emPower + 1) * powerThrowUpper);
                    pillow.transform.parent = transform.parent;

                    top.SetInteger("CurrentState", 3);
                    StartCoroutine(ThrowFinish());
                    emPower = 0;
                    NumPillowsHeld--;
                }

                isCancelButtonUp = true;
            }
            else if (isCancelButtonUp)
            {
                isCancelButtonUp = false;

                if (NumPillowsHeld > 0)
                {
                    Pillow pillow = Ammo.Peek();
                    pillow.ReadyToGo();

                    if (numPillowHold == 1)
                    {
                        pillow.transform.parent        = SlotRA;
                        pillow.transform.localPosition = Vector3.zero;
                        pillow.transform.localRotation = Quaternion.identity;
                    }

                    emPower = minThrowPower;
                    top.SetInteger("CurrentState", 1);
                }
            }

            if (!isCancelButtonUp && emPower > 0)
            {
                emPower = Mathf.Min(emPower + powerToAddEachFrame * Time.fixedDeltaTime, maxThrowPower);
            }

            if (controller.isGrounded)
            {
                // We are grounded, so recalculate
                // move direction directly from axes

                moveDirection = new Vector3(Input.GetAxis("Horizontal" + ControllerId), 0.0f, Input.GetAxis("Vertical" + ControllerId));
                if (moveDirection.sqrMagnitude > 0.2f)
                {
                    //moveDirection = Quaternion.Euler(0, -45, 0) * transform.TransformDirection(moveDirection);
                    moveDirection = moveDirection.normalized;

                    top.SetFloat("Speed", speed);
                    buttom.SetFloat("Speed", speed);
                    model.transform.forward = moveDirection;
                }
                else
                {
                    moveDirection = Vector3.zero;

                    top.SetFloat("Speed", 0);
                    buttom.SetFloat("Speed", 0);
                }

                //if (Input.GetButton("Jump"))
                //{
                //    moveDirection.y = jumpSpeed;
                //}
            }

            // Apply gravity
            moveDirection.y = moveDirection.y - (gravity * Time.fixedDeltaTime);

            controller.Move(moveDirection * speed * Time.fixedDeltaTime);
        }
    }