示例#1
0
 // Use this for initialization
 void Start()
 {
     anim    = gameObject.GetComponent <Animator>();
     tank    = waterTankObj.GetComponent <WaterTank>();
     gogoapi = gogoAPIObj.GetComponent <GogoAPI>();
     TalkToGoGo_tankIsFullOut();
 }
示例#2
0
    public void Example3()
    {
        int[] t = new int[] {
            9,
            3,
            4,
            8,
            1,
            2,
            5,
            7,
            6
        };
        int[] x = new int[] {
            123,
            456,
            789,
            1011,
            1213,
            1415,
            1617,
            1819,
            2021
        };
        int    C          = 11;
        double __expected = 2019.1666666666665;
        double __result   = new WaterTank().minOutputRate(t, x, C);

        AssertTcEqualTo(__expected, __result);
    }
        static void Main(string[] args)
        {
            var large = new LargeAirPump();

            var tank = new WaterTank(large);

            var fishes = new List <Fish>();

            fishes.Add(new Fish(AnimalSize.Tiny));
            fishes.Add(new Fish(AnimalSize.Tiny));
            fishes.Add(new Fish(AnimalSize.Tiny));
            fishes.Add(new Fish(AnimalSize.Tiny));
            fishes.Add(new Fish(AnimalSize.Small));
            fishes.Add(new Fish(AnimalSize.Small));
            fishes.Add(new Fish(AnimalSize.Small));
            fishes.Add(new Fish(AnimalSize.Medium));
            fishes.Add(new Fish(AnimalSize.Medium));
            fishes.Add(new Fish(AnimalSize.Large));

            tank.Animals.AddRange(fishes);

            var crabs = new List <Crab>();

            crabs.Add(new Crab(AnimalSize.Small));
            crabs.Add(new Crab(AnimalSize.Medium));

            tank.Animals.AddRange(crabs);

            tank.StartTheBattleOfLife();
        }
示例#4
0
 public CoffeeMachine()
 {
     _beanTank  = new CoffeeBeanTank();
     _waterTank = new WaterTank();
     _disposal  = new CoffeeDisposal();
     _grinder   = new CoffeeGrinder();
 }
        static void Main(string[] args)
        {
            var waterTank = new WaterTank()
            {
                Capacity = 100.0m, CurrentAmount = 0.0m
            };
            var commandManager = new CommandManager();

            commandManager.Invoke(new FillWaterTankCommand(waterTank, 50.0m));
            Console.WriteLine(waterTank);
            commandManager.Invoke(new FillWaterTankCommand(waterTank, 60.0m));
            Console.WriteLine(waterTank);
            commandManager.Invoke(new FillWaterTankCommand(waterTank, 10.0m));
            Console.WriteLine(waterTank);
            commandManager.Undo();
            Console.WriteLine(waterTank);

            commandManager.Invoke(new UnfillWaterTankCommand(waterTank, 10.0m));
            Console.WriteLine(waterTank);
            commandManager.Invoke(new UnfillWaterTankCommand(waterTank, 100.0m));
            Console.WriteLine(waterTank);
            commandManager.Invoke(new UnfillWaterTankCommand(waterTank, 10.0m));
            Console.WriteLine(waterTank);
            commandManager.Undo();
            Console.WriteLine(waterTank);
        }
示例#6
0
    public void Example2()
    {
        int[] t = new int[] {
            5949,
            3198,
            376,
            3592,
            4019,
            3481,
            5609,
            3840,
            6092,
            4059
        };
        int[] x = new int[] {
            29,
            38,
            96,
            84,
            10,
            2,
            39,
            27,
            76,
            94
        };
        int    C          = 1000000000;
        double __expected = 0.0;
        double __result   = new WaterTank().minOutputRate(t, x, C);

        AssertTcEqualTo(__expected, __result);
    }
示例#7
0
    public override void Interact()
    {
        if (dirtSlot != null)
        {
            // TODO: Do it when you put items in the machine slot
            if (dirtSlot.ItemGO != null)
            {
                dirtCount = dirtSlot.Item.itemCount;

                dirtPercentage += 0.5f;

                if (dirtPercentage >= 100)
                {
                    dirtPercentage = 0;
                    dirtCount--;
                    dirtSlot.UpdateItemCount(-1);
                    sandSlot.AddItem(TileType.Sand, 1);
                }

                foreach (MachineBlock block in machineBlocks)
                {
                    WaterTank _waterTank = block.GetComponent <WaterTank>();
                    if (_waterTank != null)
                    {
                        if (_waterTank.AddWater(0.1f))
                        {
                            return;
                        }
                    }
                }
                Debug.LogError("No water tank found!");
            }
        }
    }
示例#8
0
        private static void Main(string[] args)
        {
            WaterTank        tank    = new WaterTank();
            WaterTankMonitor monitor = new WaterTankMonitor(tank);

            monitor.Fill();
            monitor.Empty();
            Console.ReadLine();
        }
示例#9
0
    private void Awake()
    {
        _instance = this;

        rb = GetComponent <Rigidbody2D>();

        waterTank = GetComponent <WaterTank>();

        waterTank.WaterLevelChanged += Player_WaterLevelChanged;
    }
示例#10
0
        public void ShouldFillWater_Success()
        {
            // Arrange
            var waterTank = new WaterTank(capacity: 1000m);

            // Act
            waterTank.Fill(300m);

            // Assert
            waterTank.CurrentVolume.Should().Be(300m);
        }
示例#11
0
        public void ShouldDrainWater_ThrowsExceptionIfCurrentVolumeIsTooLow()
        {
            // Arrange
            var waterTank = new WaterTank(capacity: 1000m);

            // Act
            Action action = () => waterTank.Drain(100m);

            // Assert
            action.Should().Throw <ArgumentException>();
        }
示例#12
0
 // Use this for initialization
 void Start()
 {
     //ModifyButton.GetComponent<Button>().onClick.AddListener(togglePump);
     gogo         = ObjectGogoAPI.GetComponent <GogoAPI>();
     buttomToggle = Time.time;
     tank         = gameObject.GetComponent <WaterTank>();
     Pump.SetActive(false);
     if (PumpSmoke != null)
     {
         PumpSmoke.SetActive(false);
     }
 }
示例#13
0
    public void Example4()
    {
        int[] t = new int[] {
            100
        };
        int[] x = new int[] {
            1000
        };
        int    C          = 12345;
        double __expected = 876.55;
        double __result   = new WaterTank().minOutputRate(t, x, C);

        AssertTcEqualTo(__expected, __result);
    }
示例#14
0
        public void ShouldDrainWater_Success()
        {
            // Arrange
            var waterTank = new WaterTank(capacity: 1000m);

            waterTank.Fill(300m);

            // Act
            var drainedVolume = waterTank.Drain(100m);

            // Assert
            drainedVolume.Should().Be(100m);
            waterTank.CurrentVolume.Should().Be(200m);
        }
示例#15
0
    public void Example0()
    {
        int[] t = new int[] {
            3,
            3
        };
        int[] x = new int[] {
            1,
            2
        };
        int    C          = 3;
        double __expected = 0.9999999999999999;
        double __result   = new WaterTank().minOutputRate(t, x, C);

        AssertTcEqualTo(__expected, __result);
    }
示例#16
0
    public void Example1()
    {
        int[] t = new int[] {
            1,
            2,
            3,
            4,
            5
        };
        int[] x = new int[] {
            5,
            4,
            3,
            2,
            1
        };
        int    C          = 10;
        double __expected = 1.9999999999999996;
        double __result   = new WaterTank().minOutputRate(t, x, C);

        AssertTcEqualTo(__expected, __result);
    }
示例#17
0
 public void InitializeComponents()
 {
     _tank          = new WaterTank();
     _button        = new Button();
     _button.Text   = "Add Water";
     _button.Click += new EventHandler(this.AddWaterButtonClick);
     _button.Dock   = DockStyle.Bottom;
     _panel         = new FlowLayoutPanel();
     _panel.SuspendLayout();
     _panel.FlowDirection = FlowDirection.TopDown;
     _panel.AutoSize      = true;
     _panel.AutoSizeMode  = AutoSizeMode.GrowAndShrink;
     _panel.Height        = _tank.Height + _button.Height + 75;
     _panel.Controls.Add(_tank);
     _panel.Controls.Add(_button);
     this.SuspendLayout();
     this.Text   = "Water System";
     this.Height = _panel.Height;
     this.Width  = _tank.Width;
     this.Controls.Add(_panel);
     _panel.ResumeLayout();
     this.ResumeLayout();
 }
示例#18
0
文件: Boid.cs 项目: umetaman/nagare
 public void SetField(WaterTank _Field)
 {
     Field = _Field;
 }
示例#19
0
 // Use this for initialization
 void Start()
 {
     particle.active = false;
     tankValue       = tank.GetComponent <WaterTank>();
     gogo            = gogoapi.GetComponent <GogoAPI>();
 }
示例#20
0
 // Use this for initialization
 void Start()
 {
     wtank = tank.GetComponent <WaterTank>();
     OK.SetActive(false);
 }
 void Awake()
 {
     this.rb         = gameObject.GetComponent <Rigidbody2D>();
     this.tankScript = tank.GetComponent <WaterTank>();
     this.audio      = gameObject.GetComponent <AudioSource>();
 }
示例#22
0
 public WaterTankMonitor(WaterTank tank)
 {
     this.tank = tank;
 }
 public FillWaterTankCommand(WaterTank waterTank, decimal amount)
 {
     _waterTank = waterTank;
     _amount    = amount;
 }
示例#24
0
 // Use this for initialization
 void Start()
 {
     watertank = WaterTank_obj.GetComponent <WaterTank>();
 }
示例#25
0
 public Pump(WaterTank tank, int pumpingCapacity)
 {
     _pumpingCapacity = pumpingCapacity;
     _itsTank         = tank;
 }