예제 #1
0
    public RiceTerrainTile(uint row, uint col, bool flooded)
    {
        this.row              = row;
        this.col              = col;
        _riceState            = RiceState.NOT_PLANTED;
        selected              = false;
        _daysPlanted          = 0;
        _daysBurning          = 0;
        _hasAlreadyBeenWorked = false;
        _weed = new Weed(this);
        _bHasAppliedHerbicide = false;
        _bHasAppliedFangueig  = false;
        _isBurningRostoll     = false;

        _tutMan = GameObject.FindGameObjectWithTag("Tutorial").GetComponent <TutorialManager> ();
        GameObject.FindGameObjectWithTag("Logic").GetComponent <TimeManager> ().addListerToDayChange(this.newDayCallback);

        _actionsDoneInTheYear = new List <int> ();
        if (flooded)
        {
            this._terrainState = RiceTerrainState.WATER;
        }
        else
        {
            this._terrainState = RiceTerrainState.SOIL_MUDDY;
        }

        _plague = new PlagueInstance(this);

        updateTerrainRepresentation();


        // Load Outline
        InstantiateImages();
    }
예제 #2
0
        public void FieldDecryptionTest()
        {
            var textField = new[]
            {
                "W#@#",
                "#W##",
                "P###"
            };
            var field    = Field.FromLines(textField);
            var initCell = new FieldCell(0, 2, FieldCellStates.Player);
            var winCell  = new FieldCell(2, 0, FieldCellStates.WinCell);
            var weed1    = new Weed(0, 0);
            var weed2    = new Weed(1, 1);

            Assert.AreEqual(field.initialCell.X, initCell.X);
            Assert.AreEqual(field.initialCell.Y, initCell.Y);
            Assert.AreEqual(field.initialCell.State, initCell.State);

            Assert.AreEqual(field.winCell.X, winCell.X);
            Assert.AreEqual(field.winCell.Y, winCell.Y);
            Assert.AreEqual(field.winCell.State, winCell.State);

            Assert.AreEqual(field.weeds[0].X, weed1.X);
            Assert.AreEqual(field.weeds[0].Y, weed1.Y);
            Assert.AreEqual(field.weeds[0].WeedState, weed1.WeedState);

            Assert.AreEqual(field.weeds[1].X, weed2.X);
            Assert.AreEqual(field.weeds[1].Y, weed2.Y);
            Assert.AreEqual(field.weeds[1].WeedState, weed2.WeedState);
        }
예제 #3
0
 public RiceTerrainTile()
 {
     GameObject.FindGameObjectWithTag("Logic").GetComponent <TimeManager>().addListerToDayChange(this.newDayCallback);
     _weed   = new Weed(this);
     _plague = new PlagueInstance(this);
     _tutMan = GameObject.FindGameObjectWithTag("Tutorial").GetComponent <TutorialManager> ();
 }
예제 #4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);


            var h       = game.player.Health;
            var s       = game.player.Scores;
            var health  = new Rectangle(new Point(42 + healthText.Width, 14), new Size((675 * h) / 100, 12));
            var health2 = new Rectangle(new Point(40 + healthText.Width, 12), new Size(139, 16));

            e.Graphics.FillRectangle(Brushes.LightGreen, 0, 0, 390, 70);
            e.Graphics.FillRectangle(Brushes.Black, health2);
            e.Graphics.FillRectangle(Brushes.Red, health);
            e.Graphics.DrawString(s.ToString(), new Font(new FontFamily("Segoe UI Symbol"), 18, FontStyle.Bold), Brushes.Black, 40 + scoreText.Width, 31);
            e.Graphics.DrawImage(healthText, 12, 12);
            e.Graphics.DrawImage(scoreText, 12, 41);
            e.Graphics.DrawImage(grannysImage, 50, 60, 64, 79);
            e.Graphics.DrawImage(houseImage, 210, 0, 150, 140);
            e.Graphics.DrawImage(fieldImage, 0, 134, game.field.Width * cellWidth, game.field.Height * cellHeight);


            foreach (var weed in game.field.weeds)
            {
                var k = Weed.BossSearch(game.field, new FieldCell(weed.X, weed.Y, FieldCellStates.Weed),
                                        game.player.CurrentPos);
                var path = GetPath(k);
                foreach (var item in path)
                {
                    weed.X = item.X;
                    weed.Y = item.Y;

                    if (weed.WeedState == WeedStates.Alive)
                    {
                        e.Graphics.DrawImage(zombImage, weed.X * cellWidth + 5, weed.Y * cellHeight + 134);
                    }

                    if (weed.WeedState == WeedStates.Dead)
                    {
                        e.Graphics.DrawImage(deadZomb, weed.X * cellWidth, weed.Y * cellHeight + 134);
                    }

                    if (weed.WeedState == WeedStates.Freezed)
                    {
                        e.Graphics.DrawImage(freezedZomb, weed.X * cellWidth + 5, weed.Y * cellHeight + 134,
                                             zombImage.Width * 1.5f, zombImage.Height * 1.5f);
                    }
                }
            }

            foreach (var bullet in bullets)
            {
                if (bullet.state == BulletState.Exist)
                {
                    e.Graphics.DrawImage(bulletImage, bullet.X * cellWidth + 21, bullet.Y * cellHeight - 40 + 114, 30, 30);
                }
            }
            e.Graphics.DrawImage(playerImage, game.player.CurrentPos.X * cellWidth, game.player.CurrentPos.Y * cellHeight + 134f, 70, 93);
        }
예제 #5
0
        public void ShootTest()
        {
            var weed   = new Weed(2, 2);
            var bullet = weed.Shoot();

            Assert.AreEqual(bullet.X, 2);
            Assert.AreEqual(bullet.Y, 3);
            bullet.MoveBullet();
            Assert.AreEqual(bullet.Y, 4);
        }
예제 #6
0
        public void SmallBossSearchTest()
        {
            var textField = new[]
            {
                "W#",
                "#P"
            };
            var field = Field.FromLines(textField);
            var expectedPathLength = 3;
            var realPathLength     = Weed.BossSearch(
                field,
                GetCurrentPosition(FieldCellStates.Weed, field),
                GetCurrentPosition(FieldCellStates.Player, field)).Length;

            Assert.AreEqual(expectedPathLength, realPathLength);
        }
예제 #7
0
    void CreateWeedPlant(GameObject go, ListItem li, string strain)
    {
        Weed newWeed = go.AddComponent <Weed>();

        go.AddComponent <MeshRenderer>();
        go.AddComponent <BoxCollider>();
        MeshFilter mf = go.AddComponent <MeshFilter>();

        Mesh newMesh = (Mesh)Resources.Load("Art_Assets/Meshes/Temp/Plants/plantTemp1", typeof(Mesh));   //XML Mesh data

        mf.mesh = newMesh;

        newWeed.Strain = strain;            //XML Data

        li = new ListItem(go, newWeed);
        itemList.Add(li);
    }
    // Weeds logic
    IEnumerator IllnessRoutine()
    {
        int c = swapEvent;

        Weed.lastSwapWithCrush = swapEvent;

        yield return(new WaitForSeconds(1f));

        while (Weed.all.Count > 0)
        {
            yield return(StartCoroutine(Utils.WaitFor(() => { return swapEvent > c && swapEvent > Weed.lastSwapWithCrush; }, 1f)));

            yield return(StartCoroutine(Utils.WaitFor(CanIWait, 0.3f)));

            Weed.Grow();
            c = swapEvent;
        }
    }
예제 #9
0
        public void BulletKillsPlayerTest()
        {
            var textField = new[]
            {
                "#@#W",
                "####",
                "###P",
                "####"
            };
            var field  = Field.FromLines(textField);
            var player = new Player(field.initialCell);
            var weed   = new Weed(GetCurrentPosition(FieldCellStates.Weed, field).X, GetCurrentPosition(FieldCellStates.Weed, field).Y);
            var bullet = weed.Shoot();

            Assert.AreEqual(false, bullet.DeadInConflict(field, player));
            bullet.MoveBullet();
            Assert.AreEqual(true, bullet.DeadInConflict(field, player));
            Assert.AreEqual(16, player.Health);
        }
예제 #10
0
    public static void Grow()
    {
        List <Slot> slots = new List <Slot> ();

        foreach (Weed weed in all)
        {
            foreach (Side side in Utils.straightSides)
            {
                if (weed.slot[side] && !weed.slot[side].block && !(weed.slot[side].chip && weed.slot[side].chip.chipType == "Sugar"))
                {
                    slots.Add(weed.slot[side]);
                }
            }
        }

        while (seed > 0)
        {
            if (slots.Count == 0)
            {
                return;
            }

            Slot target = slots.GetRandom();
            slots.Remove(target);

            if (target.chip)
            {
                target.chip.HideChip(false);
            }

            Weed newWeed = ContentAssistant.main.GetItem <Weed>("Weed");
            newWeed.transform.position = target.transform.position;
            newWeed.name             = "New_Weed";
            newWeed.transform.parent = target.transform;
            target.block             = newWeed;
            newWeed.slot             = target;
            AudioAssistant.Shot("WeedCreate");
            newWeed.Initialize();

            seed--;
        }
    }
예제 #11
0
    public static void Grow()
    {
        List <Slot> slots = new List <Slot> ();

        foreach (Weed weed in all)
        {
            foreach (Side side in Utils.straightSides)
            {
                if (weed.slot[side] && !weed.slot[side].GetBlock() && !(weed.slot[side].GetChip() && weed.slot[side].GetChip().chipType == "SugarChip"))
                {
                    slots.Add(weed.slot[side]);
                }
            }
        }

        if (slots.Count == 0)
        {
            return;
        }

        Slot target = slots[Random.Range(0, slots.Count)];

        if (target.GetChip())
        {
            target.GetChip().HideChip();
        }

        Weed newWeed = ContentAssistant.main.GetItem <Weed>("Weed");

        newWeed.transform.position = target.transform.position;
        newWeed.name             = "New_Weed";
        newWeed.transform.parent = target.transform;
        target.SetBlock(newWeed);
        newWeed.slot = target;
        newWeed.Initialize();

        ContentAssistant.main.GetItem("WeedCrush", newWeed.transform.position);
    }
예제 #12
0
 void Generate()
 {
     // floor
     Instantiate(pfOceanFloor);
     // weed patches
     for (int i = 0; i < fishCount; i++)
     {
         Vector3    p  = RandomWeedPos() + new Vector3(0, 2.5f, 0);
         GameObject go = (GameObject)Instantiate(pfFish);
         Swarm      w  = go.GetComponent <Swarm>();
         w.ai.AreaCenter     = p;
         go.transform.parent = this.transform;
     }
     // fish
     for (int i = 0; i < weedCount; i++)
     {
         Vector3    p  = RandomWeedPos();
         GameObject go = (GameObject)Instantiate(pfWeed);
         Weed       w  = go.GetComponent <Weed>();
         go.transform.position = new Vector3(p.x, 0, p.z);             // need 0 height!
     }
     // environment boulders
     for (int i = 0; i < boulderScatterCount; i++)
     {
         Vector3    p    = RandomScatterBoulderPos();
         GameObject go   = (GameObject)Instantiate(pfBoulderEnv);
         float      vscl = (0.5f + 1.5f * Random.value);
         go.transform.localScale *= vscl;
         go.transform.position    = p + new Vector3(0, 1.0f, 0);
         go.rigidbody.mass       *= vscl;
         go.transform.parent      = this.transform;
     }
     // treasure
     for (int i = 0; i < treasureCount; i++)
     {
         Vector3    p     = RandomTreasurePos();
         GameObject go    = (GameObject)Instantiate(pfTreasure);
         int        level = 1 + Tools.RandomInt(5);
         float      vscl  = Mathf.Pow(level, 0.333f);
         go.GetComponent <Treasure>().gold = level;
         go.transform.localScale          *= vscl;
         go.transform.position             = p + new Vector3(0, 1.0f, 0);
         go.rigidbody.constraints          = RigidbodyConstraints.FreezePositionZ;
         go.rigidbody.mass *= vscl;
     }
     // game boulders
     for (int i = 0; i < boulderGameCount; i++)
     {
         Vector3    p    = RandomGameBoulderPos();
         GameObject go   = (GameObject)Instantiate(pfBoulder);
         float      vscl = (0.5f + 1.75f * Random.value);
         go.transform.localScale *= vscl;
         go.transform.position    = p + new Vector3(0, 1.5f, 0);
         go.rigidbody.constraints = RigidbodyConstraints.FreezePositionZ;
         go.rigidbody.mass       *= vscl;
     }
     // tentacles
     for (int i = 0; i < tentacleCount; i++)
     {
         Vector3    p  = RandomTentaclePos();
         GameObject go = (GameObject)Instantiate(pfTentacle);
         go.transform.position = p;
     }
 }
예제 #13
0
 public async Task UpdateAsync(Weed weed)
 {
     await _repository.UpdateAsync(weed);
 }
예제 #14
0
 public async Task CreateAsync(Weed weed)
 {
     await _repository.AddAsync(weed);
 }