Esempio n. 1
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        Debug.Log($"Collection fruit {photonView.InstantiationId} for player");

        if (other.gameObject.tag == "Player")
        {
            FruitBasket fruitBasket = other.gameObject.GetComponent <FruitBasket>();
            //if (fruitBasket != null && photonView.IsMine)
            if (fruitBasket != null && other.gameObject.GetComponent <PhotonView>().IsMine)
            {
                fruitBasket.Modify(Amount);
            }

            if (this.gameObject != null)
            {
                int playerId = other.gameObject.GetComponent <PlayerSetup>().PlayerNumber;
                Debug.Log($"Collection fruit {photonView.InstantiationId} for player id {playerId}");
                OnCollected(fruitBasket.FruitCount, playerId);
                if (!photonView.IsMine && PhotonNetwork.LocalPlayer.IsMasterClient)
                {
                    photonView.RPC("DestroyFruit", RpcTarget.AllBuffered);
                }
            }
        }
    }
Esempio n. 2
0
        private static async Task <int> CreateBasket()
        {
            await using var db = GetDbContext();
            var basket = new FruitBasket
            {
                Banana = DateTime.UtcNow.Ticks.ToString(),
                Pear   = DateTime.UtcNow.Ticks.ToString()
            };
            await db.FruitBaskets.AddAsync(basket);

            await db.SaveChangesAsync();

            return(basket.ID);
        }
Esempio n. 3
0
            static void Main(String[] args)
            {
                FruitBasket basket1 = new FruitBasket();
                Fruit       apple   = new Fruit("Apple", 100, head, null);

                head.nextFruit     = apple;
                basket1.firstFruit = apple;
                Fruit mango     = new Fruit("Mango", 100, apple, null);
                Fruit pineapple = new Fruit("pineapple", 100, mango, tail);

                apple.nextFruit    = mango;
                mango.nextFruit    = pineapple;
                tail.previousFruit = pineapple;
                Driver.traverseLinkedList();
            }
Esempio n. 4
0
        //zomg layers
        //public void SaveFruitBasket(FruitBasketViewModelNope fruitBasketVM)
        //{
        //    if (fruitBasketVM.FruitBasket.FruitBasketId == 0)
        //    {
        //        //add a new fruit basket to the user
        //        RegisteredUser RUser = db.RegisteredUserList.Find(fruitBasketVM.RegisteredUser.Password);
        //        RUser.FruitBasketList.Add(fruitBasketVM.FruitBasket);
        //    }
        //    else
        //    {
        //        //update the existing fruitbasket
        //        RegisteredUser RUser = db.RegisteredUserList.Find(fruitBasketVM.RegisteredUser.Password);
        //        var RUserSelectedFruitBasket = ((from b in RUser.FruitBasketList
        //            where b.FruitBasketId == fruitBasketVM.FruitBasket.FruitBasketId
        //            select b).FirstOrDefault());

        //        if (RUserSelectedFruitBasket != null)
        //        {
        //            //var temp2 = RUser.FruitBasketList.Find(x => x.FruitBasketId == temp.FruitBasketId);
        //            RUserSelectedFruitBasket.AppleList = fruitBasketVM.FruitBasket.AppleList;
        //            RUserSelectedFruitBasket.BananaList = fruitBasketVM.FruitBasket.BananaList;
        //            RUserSelectedFruitBasket.GrapesList = fruitBasketVM.FruitBasket.GrapesList;
        //            RUserSelectedFruitBasket.KiwiList = fruitBasketVM.FruitBasket.KiwiList;
        //            RUserSelectedFruitBasket.MelonList = fruitBasketVM.FruitBasket.MelonList;
        //            RUserSelectedFruitBasket.OrangeList = fruitBasketVM.FruitBasket.OrangeList;

        //        }
        //    }
        //    db.SaveChanges();
        //}

        public void SaveFruitBasket2(FruitBasket fruitBasket)
        {
            if (fruitBasket.FruitBasketId == 0)
            {
                db.FruitBasketList.Add(fruitBasket);
            }
            else
            {
                FruitBasket dbEntry = db.FruitBasketList.Find(fruitBasket.FruitBasketId);
                if (dbEntry != null)
                {
                    dbEntry.AppleList = fruitBasket.AppleList;
                }
            }
            db.SaveChanges();
        }
Esempio n. 5
0
        public FruitBasket GetFruitBasket(int fruitBasketId)
        {
            //var db = new DBContext();

            if (fruitBasketId == 0)
            {
                FruitBasket temp2 = new FruitBasket();
                return(temp2);
            }

            FruitBasket temp = new FruitBasket();

            temp = (from b in db.FruitBasketList
                    where b.FruitBasketId == fruitBasketId
                    select b).FirstOrDefault();
            return(temp);
        }
        public ViewResult ShowExampleFruitBasket()
        {
            FruitBasket temp = new FruitBasket();

            temp.AppleList.Add(new Apple()
            {
                AppleId = 1, Color = "Red", Type = "Delicious"
            });
            temp.AppleList.Add(new Apple()
            {
                AppleId = 2, Color = "Blue", Type = "SortaDelicious"
            });
            temp.AppleList.Add(new Apple()
            {
                AppleId = 3, Color = "Green", Type = "VeryDelicious"
            });
            temp.BananaList.Add(new Banana()
            {
                BananaId = 1, Color = "Yellow", NumberOfSpots = 6
            });
            temp.GrapesList.Add(new Grapes()
            {
                GrapesId = 1, Color = "purple"
            });
            temp.KiwiList.Add(new Kiwi()
            {
                KiwiId = 1, Type = "Saanichton 12"
            });
            temp.KiwiList.Add(new Kiwi()
            {
                KiwiId = 2, Type = "Saanichton 12"
            });
            temp.MelonList.Add(new Melon()
            {
                MelonId = 1, Color = "orange", Type = "cantalope"
            });
            temp.OrangeList.Add(new Orange()
            {
                OrangeId = 1, Color = "orange", Type = "Blood"
            });

            return(View("ShowNewFruitBasket", temp));
        }
        public ViewResult NewEdit1(NewEditVM1 vm1)
        {
            //look up fruit basket with id
            bool FruitBasketExists = FruitBasketRepo.FruitBasketExists(vm1.LookupID);

            //If fruit basket doesn't exist, prompt user to create new FB(redirect to get view with error message)
            if (FruitBasketExists == false)
            {
                TempData["message"] = string.Format("The Fruit Basket specified by that ID does not exist.");
                return(View("NewEdit1"));
            }
            //If fruit basket does exist, look it up
            else
            {
                FruitBasket temp = FruitBasketRepo.GetFruitBasket(vm1.LookupID);
                //and return it with the edit2 view
                return(View("NewEdit2", temp));
            }
        }
Esempio n. 8
0
    private void DamagePlayer(Collider2D other)
    {
        if (other.gameObject.tag == "Player")
        {
            Debug.Log("Hit player");

            FruitBasket        fruitBasket        = other.gameObject.GetComponent <FruitBasket>();
            MovementController movementController = other.gameObject.GetComponent <MovementController>();
            PhotonView         photonV            = other.gameObject.GetComponent <PhotonView>();

            // if (PhotonNetwork.IsMasterClient && fruitBasket.Modifiable)
            // {
            //     fruitBasket.Modify(-_damage);
            //     movementController.KnockBack();
            // }
            if (photonV.IsMine && fruitBasket.Modifiable)
            {
                fruitBasket.Modify(-_damage);
                movementController.KnockBack();
            }
        }
    }
        public ViewResult CreateFruitBasket(FruitBasketViewModel FBVM)
        {
            FruitBasket temp = FruitBasketRepo.GetFruitBasket(FBVM.FruitBasketId);

            if (FBVM.Apple != null && FBVM.Apple.AppleId != 0)
            {
                temp.AppleList.Add(FBVM.Apple);
            }

            if (FBVM.Banana != null && FBVM.Banana.BananaId != 0)
            {
                temp.BananaList.Add(FBVM.Banana);
            }

            if (FBVM.Grapes != null && FBVM.Grapes.GrapesId != 0)
            {
                temp.GrapesList.Add(FBVM.Grapes);
            }

            if (FBVM.Kiwi != null && FBVM.Kiwi.KiwiId != 0)
            {
                temp.KiwiList.Add(FBVM.Kiwi);
            }

            if (FBVM.Melon != null && FBVM.Melon.MelonId != 0)
            {
                temp.MelonList.Add(FBVM.Melon);
            }

            if (FBVM.Orange != null && FBVM.Orange.OrangeId != 0)
            {
                temp.OrangeList.Add(FBVM.Orange);
            }

            FruitBasketRepo.SaveFruitBasket2(temp);

            return(View("ShowNewFruitBasket", temp));
        }
Esempio n. 10
0
 public void AddFruitBasket(FruitBasket fruitBasket)
 {
     //var db = new DBContext();
     db.FruitBasketList.Add(fruitBasket);
     db.SaveChanges();
 }
        //public void SaveFruitBasket(Entities.FruitBasketViewModelNope fruitBasketVM)
        //{
        //    throw new NotImplementedException();
        //}


        public void SaveFruitBasket2(FruitBasket fruitBasket)
        {
            throw new NotImplementedException();
        }
 //Implemmented interface methods
 public void AddFruitBasket(FruitBasket fruitBasket)
 {
     fruitBasketList.Add(fruitBasket);
 }
Esempio n. 13
0
 public static int CalculateRoundsToSkip(int playersGuess) =>
 Math.Abs(FruitBasket.GetFruitBasket().Weight - playersGuess) / 10 - 1;
Esempio n. 14
0
 private void MakeFruitBaskets()
 {
     basket1 = new FruitBasket();
     basket2 = new FruitBasket();
 }