Пример #1
0
 private void OnTriggerExit(Collider other)
 {
     if (other.tag == "Girl")
     {
         strategy = new NoStrategy();
     }
     GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll;
     selectedStrategy = "null";
 }
Пример #2
0
 private void OnTriggerEnter(Collider other)
 {
     strategy = selectBoxStrategy(other);
 }
Пример #3
0
        public void MangePlayer()
        {
            string CurrentcellDes = player.Currentcell.CellDescription = "Golden Box";

            box = new GoldenBox();
            if (CurrentcellDes == box.GetBoxType() && box.GetBoxType() == "Golden Box")
            {
                context = new Context(new GoldenBox());
                player.PlayerBoxs.Add(box.GetBoxType());
                foreach (string K in player.PlayerKeys)
                {
                    string k = K;
                    if (k == "Golden key")
                    {
                        context.executeStrategy();
                    }
                }
            }

            else if (CurrentcellDes == "Silver Box")
            {
                context = new Context(new SilverBox());
                player.PlayerBoxs.Add(box.GetBoxType());
                foreach (string K in player.PlayerKeys)
                {
                    string k = K;
                    if (k == "Silver key")
                    {
                        context.executeStrategy();
                    }
                }
            }
            else if (CurrentcellDes == "Bronze Box")
            {
                context = new Context(new BronzeBox());
                player.PlayerBoxs.Add(box.GetBoxType());
                foreach (string K in player.PlayerKeys)
                {
                    string k = K;
                    if (k == "Bronze Key")
                    {
                        context.executeStrategy();
                    }
                }
            }
            else if (CurrentcellDes == key.GetkeyType() && key.GetkeyType() == "Golden key")
            {
                key = new GoldenKey();
                player.PlayerKeys.Add(key.GetkeyType());
            }
            else if (CurrentcellDes == "Silver key")
            {
                key = new Silverkey();
                player.PlayerKeys.Add(key.GetkeyType());
            }
            else if (CurrentcellDes == "Bronze Key")
            {
                key = new BronzeKey();
                player.PlayerKeys.Add(key.GetkeyType());
            }
            else if (CurrentcellDes == enemy.Type())
            {
                enemy.ExecuteEnemyStrategy();
            }
            else if (CurrentcellDes == diamond.getType())
            {
                Console.WriteLine("Congratulation You are The winner");
            }
            else
            {
                Console.WriteLine(" Exit ");
            }
        }
Пример #4
0
 public Context(IBoxStrategy strategy)
 {
     this.strategy = strategy;
 }