Exemplo n.º 1
0
    protected void btnGo_Click(object sender, EventArgs e)
    {
        obj          = new Reproduce();
        dtSongsTable = ((DataTable)Session["TBLSONGS"]).Copy();
        //look for the sound among the three songs
        string value = "";

        if (ddlFrog.SelectedIndex == 0 && ddlDragonFly.SelectedIndex == 0 && ddlCriket.SelectedIndex == 0)
        {
            lblMensaje.Text = "You have selected no sound!!";
        }
        else
        {
            if (ddlFrog.SelectedIndex > 0)
            {
                value = ddlFrog.SelectedValue;
            }
            if (ddlDragonFly.SelectedIndex > 0)
            {
                value = ddlDragonFly.SelectedValue;
            }
            if (ddlCriket.SelectedIndex > 0)
            {
                value = ddlCriket.SelectedValue;
            }

            lblMensaje.Text = obj.captureMessage(value, dtSongsTable);
        }
    }
Exemplo n.º 2
0
    void Start()
    {
        float initialDelay = 0.0f;
        float interval     = 1.0f;

        this.genes     = GetComponent <Genes>();
        this.hunger    = GetComponent <Hunger>();
        this.thirst    = GetComponent <Thirst>();
        this.reproduce = GetComponent <Reproduce>();

        InvokeRepeating("metabolize", initialDelay, interval);
    }
Exemplo n.º 3
0
        public void RandomChangeActionsTest()
        {
            var strategyStr     = "00000:3,00001:4,00002:0,00010:0,00011:4,00012:2,00020:1,00021:4,00022:0,00100:2,00101:4,00102:0,00110:2,00111:4,00112:0,00120:2,00121:4,00122:2,00200:0,00201:0,00202:0,00210:0,00211:4,00212:0,00220:0,00221:4,00222:1,01000:3,01001:4,01002:0,01010:0,01011:4,01012:0,01020:2,01021:0,01022:1,01100:1,01101:4,01102:1,01110:1,01111:1,01112:1,01120:1,01121:1,01122:4,01200:1,01201:4,01202:1,01210:3,01211:1,01212:1,01220:0,01221:1,01222:6,02000:3,02001:4,02002:1,02010:3,02011:4,02012:1,02020:1,02021:1,02022:1,02100:3,02101:4,02102:1,02110:6,02111:4,02112:1,02120:1,02121:2,02122:2,02200:0,02201:4,02202:2,02210:0,02211:3,02212:2,02220:2,02221:2,02222:2,10000:0,10001:4,10002:5,10010:0,10011:4,10012:2,10020:2,10021:2,10022:2,10100:2,10101:4,10102:1,10110:2,10111:2,10112:6,10120:2,10121:4,10122:6,10200:4,10201:2,10202:0,10210:6,10211:4,10212:3,10220:6,10221:3,10222:6,11000:3,11001:4,11002:2,11010:3,11011:5,11012:3,11020:0,11021:4,11022:3,11100:3,11101:3,11102:3,11110:3,11111:3,11112:3,11120:1,11121:3,11122:3,11200:3,11201:3,11202:3,11210:3,11211:3,11212:3,11220:3,11221:3,11222:3,12000:0,12001:2,12002:3,12010:3,12011:4,12012:4,12020:0,12021:4,12022:0,12100:5,12101:4,12102:4,12110:4,12111:4,12112:0,12120:3,12121:4,12122:4,12200:6,12201:4,12202:4,12210:6,12211:4,12212:0,12220:4,12221:4,12222:4,20000:3,20001:4,20002:4,20010:3,20011:4,20012:4,20020:1,20021:4,20022:4,20100:2,20101:4,20102:4,20110:5,20111:5,20112:5,20120:5,20121:5,20122:1,20200:5,20201:5,20202:3,20210:5,20211:4,20212:5,20220:5,20221:5,20222:5,21000:5,21001:4,21002:5,21010:5,21011:5,21012:5,21020:1,21021:5,21022:5,21100:5,21101:5,21102:4,21110:5,21111:3,21112:5,21120:5,21121:5,21122:2,21200:5,21201:6,21202:6,21210:3,21211:6,21212:6,21220:6,21221:6,21222:6,22000:2,22001:6,22002:6,22010:3,22011:4,22012:6,22020:6,22021:6,22022:6,22100:6,22101:6,22102:6,22110:4,22111:6,22112:6,22120:6,22121:6,22122:6,22200:6,22201:6,22202:3,22210:2,22211:6,22212:4,22220:6,22221:6,22222:0,";
            var compareStrategy = StringHelper.ConvertStringToStarategy(strategyStr);

            var orginalStrategy = StringHelper.ConvertStringToStarategy(strategyStr);

            var reproduce          = new Reproduce();
            var wantToChangeNumber = 1;
            var newStrategy        = reproduce.RandomChangeActions(orginalStrategy, wantToChangeNumber);
            var count = compareStrategy.Lines.Count(s => newStrategy.Lines.First(x => x.Key == s.Key).Value != s.Value);

            Assert.IsTrue(count == wantToChangeNumber);
        }
    public override bool decide(StateController controller)
    {
        Hunger    hunger    = controller.GetComponent <Hunger>();
        Thirst    thirst    = controller.GetComponent <Thirst>();
        Reproduce reproduce = controller.GetComponent <Reproduce>();

        if (hunger.currentHunger >= thirst.currentThirst && hunger.currentHunger >= reproduce.currentReproduce)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Exemplo n.º 5
0
    void Start()
    {
        this.genes = GetComponent <Genes>();

        this.hunger    = GetComponent <Hunger>();
        this.thirst    = GetComponent <Thirst>();
        this.reproduce = GetComponent <Reproduce>();

        if (this.nameText != null)
        {
            this.nameText.text = this.gameObject.transform.name;
        }

        if (this.currentStateText != null)
        {
            this.currentStateText.text = this.currentState.name;
        }
    }
Exemplo n.º 6
0
    private void createTemporalTable()
    {
        obj          = new Reproduce();
        dtSongsTable = new DataTable();
        DataColumn dcIdSecuencial = new DataColumn("SECUENCIAL", Type.GetType("System.Int32"));
        DataColumn dcNumSong      = new DataColumn("NUMSONG", Type.GetType("System.Int32"));
        DataColumn dcSoundValue   = new DataColumn("SOUNDVALUE", Type.GetType("System.String"));
        DataColumn dcSoundText    = new DataColumn("SOUNDTEXT", Type.GetType("System.String"));

        dtSongsTable.Columns.AddRange(new DataColumn[] { dcIdSecuencial, dcNumSong, dcSoundValue, dcSoundText });

        int numCancion = 1;

        counter = 0;
        obj.createRows(ref dtSongsTable, ref counter, numCancion);

        numCancion = 2;
        obj.createRows(ref dtSongsTable, ref counter, numCancion);

        numCancion = 3;
        obj.createRows(ref dtSongsTable, ref counter, numCancion);
    }
Exemplo n.º 7
0
        protected override void Build()
        {
            // Load Material
            ModelMat = CreateModelMat();

            // Get GameObjects
            Prefab      = PrefabUtils.CopyPrefab(BaseItem);
            Prefab.name = NamePrefix + Name;
            Prefab.transform.localScale = Scale;

            GameObject child = Prefab.FindChild("Body");

            child.transform.localScale = ModelScale;

            GameObject child2 = Prefab.transform.Find("Hen Hen/mesh_body1").gameObject;

            // Load Components
            Rigidbody    body = Prefab.GetComponent <Rigidbody>();
            Vacuumable   vac  = Prefab.GetComponent <Vacuumable>();
            Identifiable iden = Prefab.GetComponent <Identifiable>();

            Reproduce rep = Prefab.GetComponent <Reproduce>();
            TransformChanceOnReproduce trans = Prefab.GetComponent <TransformChanceOnReproduce>();

            MeshFilter          model   = child.GetComponent <MeshFilter>();
            SkinnedMeshRenderer mRender = child2.GetComponent <SkinnedMeshRenderer>();

            // Setup Components
            body.mass = Mass;
            vac.size  = Size;
            iden.id   = ID;

            if (IsFemale)
            {
                rep.nearMateId = GameContext.Instance.LookupDirector.GetPrefab(MateID).GetComponent <Identifiable>();

                List <Identifiable> ids = new List <Identifiable>()
                {
                    GameContext.Instance.LookupDirector.GetPrefab(Identifiable.Id.HEN).GetComponent <Identifiable>(),
                    GameContext.Instance.LookupDirector.GetPrefab(Identifiable.Id.PAINTED_HEN).GetComponent <Identifiable>(),
                    GameContext.Instance.LookupDirector.GetPrefab(Identifiable.Id.BRIAR_HEN).GetComponent <Identifiable>(),
                    GameContext.Instance.LookupDirector.GetPrefab(Identifiable.Id.STONY_HEN).GetComponent <Identifiable>(),
                    GameContext.Instance.LookupDirector.GetPrefab(Identifiable.Id.ELDER_HEN).GetComponent <Identifiable>()
                };

                if (DensityIDs != null)
                {
                    foreach (Identifiable.Id id in DensityIDs)
                    {
                        Identifiable toAdd = GameContext.Instance.LookupDirector.GetPrefab(id).GetComponent <Identifiable>();
                        if (!ids.Contains(toAdd))
                        {
                            ids.Add(toAdd);
                        }
                    }
                }

                rep.densityIds            = ids.ToArray();
                rep.childPrefab           = GameContext.Instance.LookupDirector.GetPrefab(ChildID);
                rep.minReproduceGameHours = MinReproduceGameHours;
                rep.maxReproduceGameHours = MaxReproduceGameHours;
            }
            else
            {
                Object.Destroy(rep);
            }

            if (!IsElder)
            {
                trans.transformChance = ElderChance;
                trans.targetPrefab    = GameContext.Instance.LookupDirector.GetPrefab(ElderID);
            }
            else
            {
                Object.Destroy(trans);
            }

            model.sharedMesh       = Mesh;
            mRender.sharedMaterial = ModelMat;

            foreach (MeshRenderer render in Prefab.transform.Find("Hen Hen/root").GetComponentsInChildren <MeshRenderer>())
            {
                if (render.sharedMaterial.name.Equals("HenHen"))
                {
                    render.sharedMaterial = ModelMat;
                }
            }
        }
 private void Start()
 {
     this.hunger    = GetComponent <Hunger>();
     this.thirst    = GetComponent <Thirst>();
     this.reproduce = GetComponent <Reproduce>();
 }
Exemplo n.º 9
0
        private void makeAMove()
        {
            energy--;
            Stopwatch stopwatch = Stopwatch.StartNew();
            stopwatch.Stop();
            int index = decideAction();
            long time = stopwatch.ElapsedMilliseconds;
            Stopwatch stopwatch2 = Stopwatch.StartNew();
            ActionInterface action = new NoMovement(world, this);
            switch (index)
            {
                case 0:
                    action = new MoveRight(world, this);
                    break;
                case 1:
                    action = new MoveLeft(world, this);
                    break;
                case 2:
                    action = new MoveUp(world, this);
                    break;
                case 3:
                    action = new MoveDown(world, this);
                    break;
                case 4:
                    if (world.isReproductionAllowed() &&
                        this.canReproduce())
                    {
                        action = new Reproduce(world, this);
                    }
                    break;
                case 5:
                    action = new Eat(world, this);
                    break;
                default:
                    throw new Exception("Trying to make an unknown move");
            }
            stopwatch2.Stop();
            long time2 = stopwatch2.ElapsedMilliseconds;

            Stopwatch stopwatch3 = Stopwatch.StartNew();
            bool successfull = action.perform();
            stopwatch3.Stop();
            long time3 = stopwatch3.ElapsedMilliseconds;

            Stopwatch stopwatch4 = Stopwatch.StartNew();
            if (successfull)
            {
                actions.Add(action);
            }
            else
            {
                actions.Add(new NoMovement(world, this));
            }
            stopwatch4.Stop();
            long time4 = stopwatch4.ElapsedMilliseconds;
            if (time > 1 || time2 > 1 || time3 > 1 || time4 > 1)
            {
                time = time; //DUMMY
            }
        }