Exemple #1
0
        private void pbMap_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            world.DrawMap(e.Graphics);
            world.DrawPlayer_Enemies(e.Graphics);
            world.DrawItems(e.Graphics);
            foreach (Enemy en in world.Enemies)
            {
                if (world.Player.Position == en.Position && !en.Dead)
                {
                    world.Player.GetHit();
                }
            }
            Cell cell = world.Map.GetCell(world.Player.Position);

            if (cell.Item != null)
            {
                ICarryable item = cell.Item;
                world.Player.PickUp(item, cell);
            }
            if (world.Player.Hitpoints <= 0)
            {
                this.Hide();
                MessageBox.Show("Game over");
                Application.Exit();
            }
            if (world.Player.Position == goal)
            {
                this.Hide();
                MessageBox.Show("You won");
                Application.Exit();
            }
        }
Exemple #2
0
        public void Run(INTERACTIBLE_TYPE originType, Transform _objectToCarry)
        {
            objectToCarry = _objectToCarry;
            carryable     = objectToCarry.GetComponent <ICarryable>();

            IsActive = true;
        }
Exemple #3
0
 public void SwitchScenes()
 {
     if (carryable != null)
     {
         isCarrying = false;
         canAttack  = true;
         carryable  = null;
     }
 }
Exemple #4
0
 public void PickUp(ICarryable item, Cell cell)
 {
     currentweight += item.Weight;
     if (maxweight >= currentweight)
     {
         this.item  = item;
         Hitpoints += item.Hitpoints;
         cell.Item  = null;
     }
 }
Exemple #5
0
 private static bool CanPickup(SeinCharacter sein)
 {
     if (sein.Controller.CanMove && sein.PlatformBehaviour.PlatformMovement.IsOnGround)
     {
         for (int i = 0; i < Items.Carryables.Count; i++)
         {
             ICarryable carryable = Items.Carryables[i];
             if (Vector3.Distance(((Component)carryable).transform.position, sein.Position) < sein.Abilities.Carry.CarryRange && carryable != null && carryable.CanBeCarried())
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemple #6
0
 /// <summary>
 /// Put the Item in your backpack.
 /// </summary>
 /// <param name="item">Item.</param>
 public void PickUp(ICarryable item)
 {
     // if you already have some of this item, put it with those.
     if (Backpack.ContainsKey(item.Name))
     {
         Backpack [item.Name].Add(item);
     }
     // otherwise start a new stack
     else
     {
         Backpack.Add(item.Name, new List <ICarryable>()
         {
             item
         });
     }
 }
Exemple #7
0
    public void PickupCarryable(Collision2D collision)
    {
        ICarryable carryable = collision.collider.GetComponent <Ball>();

        if (carryable != null)
        {
            if (!isCarrying && timeSinceLastCarry >= carryCooldown &&
                collision.collider.CompareTag(GameManager.Constants.CARRYABLE_TAG))
            {
                GameManager.Constants.LayerToLayerMask(1);
                carryable.Pickup(transform, carryPosition);
                isCarrying     = true;
                canAttack      = false;
                this.carryable = carryable;
                // Physics2D.IgnoreLayerCollision(GameManager.Constants.PLAYER_LAYER, GameManager.Constants.CARRYABLE_LAYER);
            }
        }
    }