// Update is called once per frame void Update() { // py.Communication(Agentid, LaraModel, Marko, HalloModel, this, Hallo, Lara, this.Dopamin, this.OxetocinForHallo, this.OxetocinForLara); if (Food == 0) { FoodZerotimeSec += Time.deltaTime; FoodZerotime = (int)FoodZerotimeSec; if (FoodZerotime == 3) { Health = 0; } } if (DieAgent.MarkoLive == true) { AgentReset(); } // DeadTime if (this.Health <= 0) { DieAgent.MarkoDied = true; Player.active = false; } Vector3 targetPos = AnimZombie.transform.position; Timepassed += Time.deltaTime; seconds = (int)Timepassed; // action = py.AgentAction; if (seconds == count) { count += 1; action = Random.Range(0, 7); healthinc = false; once = false; } //after two seconds if (seconds == i) { if (Food > 0) { Food = Food - 0.5f; if (FoodFiller.size.x > 0) { this.FoodFiller.size = new Vector2(this.FoodFiller.size.x - 0.02f, this.FoodFiller.size.y); } } i += 2; } if (PrevFood - Food == 1) { Health -= 0.5f; if (HealthFiller.size.x > 0) { this.HealthFiller.size = new Vector2(this.HealthFiller.size.x - 0.02f, this.HealthFiller.size.y); } PrevFood = Food; } //To increase Dopamine level according to food level increment //if (Food - PrevFoodForDopamin >= 5) //{ // this.Dopamin++; // PrevFoodForDopamin = Food; //} float dist1 = Vector3.Distance(Marko.transform.position, Food1.transform.position); dist = dist1; //Eat action float dist2 = Vector3.Distance(Hallo.transform.position, Food2.transform.position); float dist3 = Vector3.Distance(Hallo.transform.position, Food3.transform.position); float distWithLara = Vector3.Distance(Hallo.transform.position, Lara.transform.position); float distWithHallo = Vector3.Distance(Hallo.transform.position, Hallo.transform.position); if (action == 5 && once == false && (dist1 < 1.42 || dist2 < 1.42 || dist3 < 1.42)) { Food++; if (FoodFiller.size.x < 1) { this.FoodFiller.size = new Vector2(this.FoodFiller.size.x + 0.02f, this.FoodFiller.size.y); } once = true; AddReward(+1.0f); } else if (action == 5 && once == false && (distWithLara < 1.42)) { Food++; if (FoodFiller.size.x < 1) { this.FoodFiller.size = new Vector2(this.FoodFiller.size.x + 0.02f, this.FoodFiller.size.y); } Lara.Food--; AddReward(+1.0f); once = true; } else if (action == 5 && once == false && (distWithHallo < 1.42)) { Food++; Hallo.interactionWithMarko++; AddReward(+1.0f); if (FoodFiller.size.x < 1) { this.FoodFiller.size = new Vector2(this.FoodFiller.size.x + 0.02f, this.FoodFiller.size.y); } Hallo.Food--; once = true; } if (Food - PrevFood == 1 && healthinc == false) { Health++; if (HealthFiller.size.x < 1) { this.HealthFiller.size = new Vector2(this.HealthFiller.size.x + 0.02f, this.HealthFiller.size.y); } healthinc = true; } //Run Agent Animation if (action == 1 || action == 2 || action == 3 || action == 4) { AnimZombie.SetTrigger("run"); } //Stop Agent Animation // if (Input.GetKeyUp(KeyCode.UpArrow) || Input.GetKeyUp(KeyCode.DownArrow) || Input.GetKeyUp(KeyCode.LeftArrow) || Input.GetKeyUp(KeyCode.RightArrow) || Input.GetKeyUp(KeyCode.A)) if (action == 0) { AnimZombie.SetTrigger("idle"); } //Attack Agent Animation //if(Hallo.RLForMarko >= Hallo.RLForLara) //{ // AttackedByHallo = true; //} if (Hallo.action == 7 && Vector3.Distance(this.transform.position, Hallo.transform.position) < 3 /*&& AttackedByHallo && Hallo.OxetocinForMarko < 3*/) { //if (OxetocinForHallo > 0) //{ // OxetocinForHallo -= 0.5f; //} if (Food > 0) { Food--; } transform.LookAt(Hallo.transform.position); AnimZombie.SetTrigger("attack"); bulletfire.ShootBullet(AttackParticle, Player, ParticlesContainer); //Increment in Rivalary level for Hallo this.FoodFiller.size = new Vector2(this.FoodFiller.size.x - 0.02f, this.FoodFiller.size.y); // RLForHallo += 0.5f; } //if (Lara.RLForMarko >= Lara.RLForHallo) //{ // AttackedByLara = true; //} ///if Lara has action of attack if (Lara.action == 7 && Vector3.Distance(this.transform.position, Lara.transform.position) < 3 /*&& AttackedByLara && Lara.OxetocinForMarko < 1*/) { //if (OxetocinForLara > 0) //{ // OxetocinForLara -= 0.5f; //} if (Food > 0) { Food--; } transform.LookAt(Lara.transform.position); AnimZombie.SetTrigger("attack"); bulletfire.ShootBullet(AttackParticle, Player, ParticlesContainer); //Increment in Rivalary level for Lara //RLForLara += 0.5f; this.FoodFiller.size = new Vector2(this.FoodFiller.size.x - 0.02f, this.FoodFiller.size.y); } float DistanceWithHallo = Vector3.Distance(this.transform.position, Hallo.transform.position); //Share action ////Sharing with Hallo //if (action == 6 && DistanceWithHallo <= 1.42f /*&& OxetocinForHallo > 4*/) //{ // if (Food > 0) // { // this.Food -= 0.5f; // Hallo.Food += 0.5f; // } //Decrement in Rivalary Level //if (Hallo.RLForMarko > 0) //{ // Hallo.RLForMarko -= 0.5f; //} ////Hallo.OxetocinForMarko += 0.5f; //OxetocinInHalloForMarko += 0.5f; // if (this.FoodFiller.size.x > 0) // { // this.FoodFiller.size = new Vector2(this.FoodFiller.size.x - 0.02f, this.FoodFiller.size.y); // } // if (Hallo.FoodFiller.size.x < 1) // { // Hallo.FoodFiller.size = new Vector2(this.FoodFiller.size.x + 0.02f, this.FoodFiller.size.y); // } //} float DistanceWithLara = Vector3.Distance(this.transform.position, Lara.transform.position); //Sharing with Lara (Selfless) //if (action == 6 && DistanceWithLara <= 1.42f /*&& OxetocinForLara > 4*/) //{ // if (Food > 0) // { // this.Food -= 0.5f; // Lara.Food += 0.5f; // } // //if (Lara.RLForMarko > 0) // //{ // // Lara.RLForMarko -= 0.5f; // //} // if (this.FoodFiller.size.x > 0) // { // this.FoodFiller.size = new Vector2(this.FoodFiller.size.x - 0.02f, this.FoodFiller.size.y); // } // if (Lara.FoodFiller.size.x < 1) // { // Lara.FoodFiller.size = new Vector2(this.FoodFiller.size.x + 0.02f, this.FoodFiller.size.y); // } //} // AddReward(Selfish()); //Coin collection Cointime = Cointime + Time.deltaTime; Coinseconds = (int)Cointime; numberofCoins = numberofCoins + coin.coin_production(Coinseconds, Marko, Coin1, Coin2, Coin3, Coin4); //Health Kit Collection healthKit = Aidkit.AIDKIT(Coinseconds, Marko, AIDkit1, AIDkit2); if (healthKit > 0) { Health += 0.5f; this.HealthFiller.size = new Vector2(this.HealthFiller.size.x + 0.02f, this.HealthFiller.size.y); healthKit = 0; } if (Coinseconds == 5) { Cointime = 0; Coinseconds = 0; } // py.nextState(Agentid, LaraModel, Marko, HalloModel, this, Hallo, Lara, this.Dopamin, this.OxetocinForHallo, this.OxetocinForLara, this.Reward); }
// Update is called once per frame void Update() { if (Food == 0) { FoodZerotimeSec += Time.deltaTime; FoodZerotime = (int)FoodZerotimeSec; if (FoodZerotime == 3) { Health = 0; } } if (DieAgent.HalloLive == true) { AgentReset(); } // DeadTime if (this.Health <= 0) { DieAgent.HalloDied = true; Player.active = false; } Vector3 targetPos = Hallo.transform.position; targetPos.y = 0; Timepassed += Time.deltaTime; Timecheck += Time.deltaTime; seconds = (int)Timepassed; if (seconds == count) { count += 1; action = Random.Range(0, 7); healthinc = false; once = false; } if (seconds == i) { if (Food > 0) { Food = Food - 0.5f; if (FoodFiller.size.x > 0) { this.FoodFiller.size = new Vector2(this.FoodFiller.size.x - 0.02f, this.FoodFiller.size.y); } } i += 2; } if (PrevFood - Food == 1) { Health -= 0.5f; if (HealthFiller.size.x > 0) { this.HealthFiller.size = new Vector2(this.HealthFiller.size.x - 0.02f, this.HealthFiller.size.y); } PrevFood = Food; } float CoinDist = Vector3.Distance(Hallo.transform.position, Coin1.transform.position); float dist1 = Vector3.Distance(Hallo.transform.position, Food1.transform.position); float dist2 = Vector3.Distance(Hallo.transform.position, Food2.transform.position); float dist3 = Vector3.Distance(Hallo.transform.position, Food3.transform.position); float distWithLara = Vector3.Distance(Hallo.transform.position, Lara.transform.position); float distWithMarko = Vector3.Distance(Hallo.transform.position, Marko.transform.position); //Eat if interaction with Marko is more if (action == 5 && once == false && (dist1 < 1.42 || dist2 < 1.42 || dist3 < 1.42) && seconds >= 5 && interactionWithMarko >= interactionWithLara && interactionWithMarko > 0) { Food++; this.FoodFiller.size = new Vector2(this.FoodFiller.size.x + 0.02f, this.FoodFiller.size.y); once = true; if (dist1 < 1.42) { Food1.SetActive(false); Timecheck = 0; } else if (dist2 < 1.42f) { Food2.SetActive(false); Timecheck = 0; } else if (dist3 < 1.42f) { Food3.SetActive(false); Timecheck = 0; } } else if (action == 5 && once == false && (distWithLara < 1.42) && seconds >= 5 && interactionWithMarko >= interactionWithLara && interactionWithMarko > 0) { Food++; if (FoodFiller.size.x < 1) { this.FoodFiller.size = new Vector2(this.FoodFiller.size.x + 0.02f, this.FoodFiller.size.y); } Lara.Food--; AddReward(+1.0f); once = true; } else if (action == 5 && once == false && (distWithMarko < 1.42) && seconds >= 5 && interactionWithMarko >= interactionWithLara && interactionWithMarko > 0) { Food++; AddReward(+1.0f); if (FoodFiller.size.x < 1) { this.FoodFiller.size = new Vector2(this.FoodFiller.size.x + 0.02f, this.FoodFiller.size.y); } Marko.Food--; once = true; } if ((int)Timecheck == 5) { Food1.SetActive(true); Food2.SetActive(true); Food3.SetActive(true); } if (Food - PrevFood == 1 && healthinc == false) { Health += 0.5f; this.HealthFiller.size = new Vector2(this.HealthFiller.size.x + 0.02f, this.HealthFiller.size.y); healthinc = true; } //Run Agent Animation // if (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.A)) if (action == 1 || action == 2 || action == 3 || action == 4) { AnimZombie.SetTrigger("run"); } //Stop Agent Animation // if (Input.GetKeyUp(KeyCode.UpArrow) || Input.GetKeyUp(KeyCode.DownArrow) || Input.GetKeyUp(KeyCode.LeftArrow) || Input.GetKeyUp(KeyCode.RightArrow) || Input.GetKeyUp(KeyCode.A)) if (action == 0) { AnimZombie.SetTrigger("idle"); } //Attack Agent Animation //if (Input.GetKeyDown(KeyCode.A)) if (action == 7) { AnimZombie.SetTrigger("attack"); bulletfire.ShootBullet(AttackParticle, Player, ParticlesContainer); } if (Vector3.Distance(this.transform.position, Marko.transform.position) < 3) { transform.LookAt(Marko.transform.position); AnimZombie.SetTrigger("attack"); bulletfire.ShootBullet(AttackParticle, Player, ParticlesContainer); Marko.Food--; if (Marko.FoodFiller.size.x > 0) { Marko.FoodFiller.size = new Vector2(Marko.FoodFiller.size.x - 0.02f, Marko.FoodFiller.size.y); } } if (Vector3.Distance(this.transform.position, Lara.transform.position) < 3) { transform.LookAt(Lara.transform.position); AnimZombie.SetTrigger("attack"); bulletfire.ShootBullet(AttackParticle, Player, ParticlesContainer); Lara.Food--; //Lara.FoodFiller.size = new Vector2(Lara.FoodFiller.size.x - 0.02f, Lara.FoodFiller.size.y); if (Lara.FoodFiller.size.x > 0) { Lara.FoodFiller.size = new Vector2(Lara.FoodFiller.size.x - 0.02f, Lara.FoodFiller.size.y); } } float DistanceWithMarko = Vector3.Distance(this.transform.position, Marko.transform.position); float distanceWithLara = Vector3.Distance(this.transform.position, Lara.transform.position); if (action == 6 && DistanceWithMarko <= 1.42f && seconds >= 5 && interactionWithMarko <= interactionWithLara) { this.Food -= 0.5f; Marko.Food += 0.5f; AddReward(1f); if (this.FoodFiller.size.x > 0) { this.FoodFiller.size = new Vector2(this.FoodFiller.size.x - 0.02f, this.FoodFiller.size.y); } if (Marko.FoodFiller.size.x <= 1) { Marko.FoodFiller.size = new Vector2(this.FoodFiller.size.x + 0.02f, this.FoodFiller.size.y); } } else if (action == 6 && distanceWithLara <= 1.42f && seconds >= 5 && interactionWithMarko <= interactionWithLara) { this.Food -= 0.5f; Marko.Food += 0.5f; AddReward(1f); if (this.FoodFiller.size.x > 0) { this.FoodFiller.size = new Vector2(this.FoodFiller.size.x - 0.02f, this.FoodFiller.size.y); } if (Marko.FoodFiller.size.x <= 1) { Marko.FoodFiller.size = new Vector2(this.FoodFiller.size.x + 0.02f, this.FoodFiller.size.y); } } Cointime = Cointime + Time.deltaTime; Coinseconds = (int)Cointime; numberofCoins = numberofCoins + coin.coin_production(Coinseconds, Hallo, Coin1, Coin2, Coin3, Coin4); healthKit = Aidkit.AIDKIT(Coinseconds, Hallo, AIDkit1, AIDkit2); if (healthKit > 0) { Health += 0.5f; this.HealthFiller.size = new Vector2(this.HealthFiller.size.x + 0.02f, this.HealthFiller.size.y); healthKit = 0; } if (Coinseconds == 10) { Cointime = 0; Coinseconds = 0; } }
// Update is called once per frame void Update() { //this.action = 0; // py.Communication(id, LaraModel, MarkoModel, HalloModel, Marko, Hallo, this, this.Dopamin, this.OxetocinForHallo, this.OxetocinForMarko); if (Food == 0) { FoodZerotimeSec += Time.deltaTime; FoodZerotime = (int)FoodZerotimeSec; if (FoodZerotime == 3) { Health = 0; } } if (DieAgent.LaraLive == true) { AgentReset(); } // DeadTime if (this.Health <= 0) { DieAgent.LaraDied = true; Player.active = false; } Vector3 targetPos = AnimZombie.transform.position; Timepassed += Time.deltaTime; Timecheck += Time.deltaTime; seconds = (int)Timepassed; //action = py.AgentAction; if (seconds == count) { count += 1; action = Random.Range(1, 7); healthinc = false; once = false; } if (seconds == i) { if (Food > 0) { Food = Food - 0.5f; if (FoodFiller.size.x > 0) { this.FoodFiller.size = new Vector2(this.FoodFiller.size.x - 0.02f, this.FoodFiller.size.y); } } i += 2; } if (PrevFood - Food == 1) { Health -= 0.5f; if (HealthFiller.size.x > 0) { this.HealthFiller.size = new Vector2(this.HealthFiller.size.x - 0.02f, this.HealthFiller.size.y); } //this.HealthFiller.size = new Vector2(this.HealthFiller.size.x - 0.02f, this.HealthFiller.size.y); PrevFood = Food; } float dist1 = Vector3.Distance(Hallo.transform.position, Food1.transform.position); float dist2 = Vector3.Distance(Hallo.transform.position, Food2.transform.position); float dist3 = Vector3.Distance(Hallo.transform.position, Food3.transform.position); if (action == 5 && once == false && (dist1 < 1.42 || dist2 < 1.42 || dist3 < 1.42)) { Food++; if (FoodFiller.size.x <= 1) { this.FoodFiller.size = new Vector2(this.FoodFiller.size.x + 0.02f, this.FoodFiller.size.y); } once = true; if (dist1 < 1.42) { Food1.SetActive(false); Timecheck = 0; } else if (dist2 < 1.42f) { Food2.SetActive(false); Timecheck = 0; } else if (dist3 < 1.42f) { Food3.SetActive(false); Timecheck = 0; } } if ((int)Timecheck == 5) { Food1.SetActive(true); Food2.SetActive(true); Food3.SetActive(true); } if (Food - PrevFood == 1 && healthinc == false) { Health += 0.5f; this.HealthFiller.size = new Vector2(this.HealthFiller.size.x + 0.02f, this.HealthFiller.size.y); healthinc = true; } //Run Agent Animation if (action == 1 || action == 2 || action == 3 || action == 4) { AnimZombie.SetTrigger("run"); } //Stop Agent Animation // if (Input.GetKeyUp(KeyCode.UpArrow) || Input.GetKeyUp(KeyCode.DownArrow) || Input.GetKeyUp(KeyCode.LeftArrow) || Input.GetKeyUp(KeyCode.RightArrow) || Input.GetKeyUp(KeyCode.A)) if (action == 0) { AnimZombie.SetTrigger("idle"); } //Attack Agent Animation //if (Hallo.RLForLara > Hallo.RLForMarko) //{ // AttackedByHallo = true; //} //action 7 is attack if (Hallo.action == 7 && Vector3.Distance(this.transform.position, Hallo.transform.position) < 3 /*&& AttackedByHallo && Hallo.OxetocinForLara < 3*/) { //if(OxetocinForHallo > 0) //{ // OxetocinForHallo -= 0.5f; //} //transform.LookAt(Hallo.transform.position); AnimZombie.SetTrigger("attack"); bulletfire.ShootBullet(AttackParticle, Player, ParticlesContainer); if (Food > 0) { Food--; this.FoodFiller.size = new Vector2(this.FoodFiller.size.x - 0.02f, this.FoodFiller.size.y); } //RLForHallo += 0.5f; } //if(Marko.RLForLara > Marko.RLForHallo) //{ // AttackedByMarko = true; //} if (Marko.action == 7 && Vector3.Distance(this.transform.position, Marko.transform.position) < 3 /*&& AttackedByMarko && Marko.OxetocinForLara < 3*/) { //if (OxetocinForMarko > 0) //{ // OxetocinForMarko -= 0.5f; //} //transform.LookAt(Marko.transform.position); AnimZombie.SetTrigger("attack"); bulletfire.ShootBullet(AttackParticle, Player, ParticlesContainer); if (Food > 0) { Food--; this.FoodFiller.size = new Vector2(this.FoodFiller.size.x - 0.02f, this.FoodFiller.size.y); } //RLForMarko += 0.5f; } float DistanceWithMarko = Vector3.Distance(this.transform.position, Marko.transform.position); //Sharing with Marko if (action == 6 && DistanceWithMarko <= 1.42f /*&& OxetocinForMarko >= 2*/) { if (Food > 0) { this.Food -= 0.5f; Marko.Food += 0.5f; // OxetocinInMarkoForLara += 0.5f; AddReward(1f); } //if (Marko.RLForLara > 0) //{ // Marko.RLForLara -= 0.5f; //} if (this.FoodFiller.size.x > 0) { this.FoodFiller.size = new Vector2(this.FoodFiller.size.x - 0.02f, this.FoodFiller.size.y); } if (Marko.FoodFiller.size.x <= 1) { Marko.FoodFiller.size = new Vector2(this.FoodFiller.size.x + 0.02f, this.FoodFiller.size.y); } } float DistanceWithHallo = Vector3.Distance(this.transform.position, Hallo.transform.position); //Sharing with hallo if (action == 6 && DistanceWithHallo <= 1.42f /*&& OxetocinForHallo >= 2*/) { Hallo.interactionWithLara++; if (Food > 0) { this.Food -= 0.5f; Hallo.Food += 0.5f; // OxetocinInHalloForLara += 0.5f; AddReward(1f); } //if (Hallo.RLForLara > 0) //{ // Hallo.RLForLara -= 0.5f; //} if (this.FoodFiller.size.x > 0) { this.FoodFiller.size = new Vector2(this.FoodFiller.size.x - 0.02f, this.FoodFiller.size.y); } //doesnt get out of the filler if (Hallo.FoodFiller.size.x <= 1) { Hallo.FoodFiller.size = new Vector2(this.FoodFiller.size.x + 0.02f, this.FoodFiller.size.y); } } //if (OxetocinInMarkoForLara - prevOxeMarko > 5) //{ // prevOxeMarko = OxetocinInMarkoForLara; // Dopamin++; //} //if (OxetocinInHalloForLara - prevOxeHallo > 5) //{ // prevOxeHallo = OxetocinInHalloForLara; // Dopamin++; //} //if (Dopamin > 5) //{ // AddReward(1f); //} if (Health <= 0) { SetReward(-1f); } //Coin collection Cointime = Cointime + Time.deltaTime; Coinseconds = (int)Cointime; numberofCoins = numberofCoins + coin.coin_production(Coinseconds, LaraModel, Coin1, Coin2, Coin3, Coin4); //Health Kit Collection healthKit = Aidkit.AIDKIT(Coinseconds, LaraModel, AIDkit1, AIDkit2); if (healthKit > 0) { Health += 0.5f; this.HealthFiller.size = new Vector2(this.HealthFiller.size.x + 0.02f, this.HealthFiller.size.y); healthKit = 0; } if (Coinseconds == 5) { Cointime = 0; Coinseconds = 0; } // py.nextState(id, LaraModel, MarkoModel, HalloModel, Marko, Hallo, this, this.Dopamin, this.OxetocinForHallo, this.OxetocinForMarko, this.Reward); }