Inheritance: MonoBehaviour
Beispiel #1
0
 private void OnTriggerEnter(Collider col)
 {
     /* if (col.gameObject.tag == "wall")
      * {
      *   if (!hasCultist)
      *   {
      *       collideWithWall = true;
      *       if (!walls.Contains(col.gameObject))
      *           walls.Add(col.gameObject);
      *   }
      * }*/
     /*else*/ if (col.gameObject.tag == "cultist")
     {
         //  hasCultist = true;
         //  if (!collideWithWall)
         //  {
         Cultist cultist = col.gameObject.GetComponent <Cultist>();
         if (cultist.IsBeast)
         {
             farmer._agent.speed = 13f;
         }
         //  }
         // --
         //else
         // Load Win screen scene
     }
 }
Beispiel #2
0
        public void Test_UsingEnlightenment_ToFindPath()
        {
            var cards = gsl("Strike", "Strike", "HeavyBlade", "Enlightenment+", "Bash");

            var enemy  = new Cultist(hp: 80, hpMax: 80);
            var player = new Player(hp: 1); //player must kill turn 2.

            //best line: play e+, bash (8+vuln), hb (21), strike (9) = 38.
            //turn 2: redraw same cards but play differently.  HB (21) S(9) b(12) = 42
            var deck = new Deck(cards, gsl(), gsl(), gsl());
            var fs   = new MonteCarlo(deck, enemy, player, firstHand: cards);
            var node = fs.SimAfterFirstDraw();

            Assert.AreEqual(1, node.GetValue().Value);
            //assert the right cards were played.
            var drawNode      = node.Choices.First();
            var enlightenment = drawNode.Choices.Single(el => el.Value.Value == 1);

            Assert.AreEqual(nameof(Enlightenment), enlightenment.FightAction.CardInstance.Card.Name);
            Assert.AreEqual(1, enlightenment.FightAction.CardInstance.UpgradeCount);

            var bash = enlightenment.Choices.Single(el => el.Value.Value == 1);

            Assert.AreEqual(nameof(Bash), bash.FightAction.CardInstance.Card.Name);
            Assert.AreEqual(0, bash.FightAction.CardInstance.UpgradeCount);
        }
Beispiel #3
0
        public void CreateEnemies()
        {
            // Enkla Monster
            Cultist  cultist  = new Cultist();
            BeefCake beefCake = new BeefCake();
            Shaman   shaman   = new Shaman();
            // Semi svåra Monster
            AngryCultist    angryCultist    = new AngryCultist();
            BeefierBeefCake beefierBeefCake = new BeefierBeefCake();
            CatHelmetShaman catHelmetShaman = new CatHelmetShaman();
            // Svåra
            DarkCultist           darkCultist           = new DarkCultist();
            BeefiestBeefCake      beefiestBeefCake      = new BeefiestBeefCake();
            DubbleCatHelmetShaman dubbleCatHelmetShaman = new DubbleCatHelmetShaman();

            listOfMonstersOne.Add(cultist);
            listOfMonstersOne.Add(beefCake);
            listOfMonstersOne.Add(shaman);
            listOfMonstersTwo.Add(angryCultist);
            listOfMonstersTwo.Add(beefierBeefCake);
            listOfMonstersTwo.Add(catHelmetShaman);
            listOfMonstersThree.Add(darkCultist);
            listOfMonstersThree.Add(beefiestBeefCake);
            listOfMonstersThree.Add(dubbleCatHelmetShaman);


            //Mellanmjölk monster

            // Hell Monster
        }
Beispiel #4
0
        public void Test_Random_Playouts()
        {
            for (var loop = 0; loop < 100; loop++)
            {
                var rcount = (int)Rnd.Next(10);
                var relics = GetRandomRelics(rcount);

                var ccount = (int)Rnd.Next(20) + 3;
                var cards  = GetRandomCards(ccount);

                var       player    = new Player(relics: relics);
                var       enemy     = new Cultist(70, 70);
                var       deck      = new Deck(cards);
                var       mc        = new MonteCarlo(deck, enemy, player);
                var       histories = new List <double>();
                FightNode root;
                //can there ever be decreasing values? yes, when we re-explore a random draw and get a worse result.
                //that's too bad.
                for (var ii = 0; ii < 10; ii++)
                {
                    root = mc.SimIncludingDraw(1000);
                    histories.Add(root.Value.Value);
                }
                Assert.IsTrue(histories.First() == 100 || histories.First() < histories.Last());
            }
        }
Beispiel #5
0
        public void Test_ExploringDrawSpace()
        {
            var cards  = gsl("Strike", "Defend");
            var enemy  = new Cultist(hp: 1, hpMax: 1);
            var player = new Player(hp: 1, maxEnergy: 1, drawAmount: 1);
            var deck   = new Deck(cards, gsl(), gsl(), gsl());
            var fs     = new MonteCarlo(deck, enemy, player);
            var root   = fs.SimIncludingDraw();

            //there should be two randomChoice nodes
            Assert.AreEqual(2, root.Choices.Count);
            Assert.AreEqual(0, root.Randoms.Count);

            foreach (var r in root.Choices)
            {
                //var v = r.GetValue();
                //endturn and play your single card.
                Assert.AreEqual(2, r.Choices.Count);
                Assert.AreEqual(0, r.Randoms.Count);

                //player can always win the fight.
                Assert.AreEqual(1, r.GetValue().Value);
            }

            //draw orders:
            // S* -win
            // DS* win
            // DD* lose
            //so Value should be 75 and the tree should be exhausted.

            // S win
            // D
            //  S  win
            //  D  lose
        }
Beispiel #6
0
    protected override void UnitUpdate()
    {
        //Do your stuff here
        Tile tile = GetComponentInParent <Tile>();

        if (terrified)
        {
            if (this.hometile && this.hometile.coord == tile.coord)
            {
                terrified = false;
            }
            else
            {
                MoveUnit(this.hometile.coord - tile.coord);
            }
            return;
        }


        if (tile is SacrificialChamber)
        {
            //Sacrifice yourself!
            PlayerController.Instance.DeltaMana(manaBoost);
            UnitDie();
        }
        else if (tile is Church)
        {
            //Dunno?
        }
        Cultist cultist = tile.GetComponentInChildren <Cultist>();

        if (cultist != null && (cultist.curLeaderState == Cultist.LeaderState.taskmaster))
        {
            dir = cultist.leaderDir;
        }
        if (dir.magnitude != 0)
        {
            MoveUnit(dir);
        }
        else
        {
            List <System.Tuple <Cultist, float> > neighborCultists = LocateGridEntity <Cultist>(1);
            //don't bother checking closest...
            for (int i = 0; i < neighborCultists.Count; i++)
            {
                if (neighborCultists[i].Item1.curLeaderState == Cultist.LeaderState.taskmaster)
                {
                    MoveUnit(neighborCultists[i].Item1.GetComponentInParent <Tile>().coord - tile.coord);
                    return;
                }
            }
        }
    }
Beispiel #7
0
        public void Test_Basic()
        {
            //I want to validate that I am properly generating all outcomes.
            var cards = gsl("Strike");

            var enemy   = new Cultist(1);
            var player  = new Player(hp: 1);
            var deck    = new Deck(cards, gsl(), gsl(), gsl());
            var fs      = new MonteCarlo(deck, enemy, player, firstHand: cards);
            var results = fs.SimAfterFirstDraw();

            Assert.AreEqual(1, results.Value.Value);
        }
Beispiel #8
0
    private void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.tag == "cultist")
        {
            TriggerEntered = true;
            Cultist cultist = col.gameObject.GetComponent <Cultist>();
            if (cultist.IsBeast)
            {
                source.PlayOneShot(source.clip);

                farmer.SetIsHunting(true, cultist.transform.position);
            }
        }
    }
Beispiel #9
0
 /* private void OnTriggerStay(Collider col)
  * {
  *   if (col.gameObject.tag == "wall")
  *   {
  *       collideWithWall = true;
  *   }
  * }
  *
  * private void OnTriggerExit(Collider col)
  * {
  *   if (col.gameObject.tag == "wall")
  *   {
  *       if (!walls.Contains(col.gameObject))
  *           walls.Remove(col.gameObject);
  *       if (walls.Count == 0)
  *           collideWithWall = false;
  *   }
  * }*/
 private void OnTriggerExit(Collider col)
 {
     if (col.gameObject.tag == "cultist")
     {
         //  hasCultist = true;
         //  if (!collideWithWall)
         //  {
         Cultist cultist = col.gameObject.GetComponent <Cultist>();
         if (cultist.IsBeast)
         {
             farmer._agent.speed = 9f;
         }
     }
 }
Beispiel #10
0
    void Start()
    {
        cult         = new Cultist();
        currentState = null;
        health       = cult.health;
        isAlive      = true;

        cult_sprites    = Resources.LoadAll <Sprite>("cultist");
        gunShot         = Resources.Load <AudioClip>("cultist_shot");
        sprite_renderer = GetComponent <SpriteRenderer>();
        cult_audio      = GetComponent <AudioSource>();

        SetState(new Attack(this));
    }
Beispiel #11
0
    private void OnTriggerStay(Collider col)
    {
        if (col.gameObject.tag == "cultist")
        {
            Cultist cultist = col.gameObject.GetComponent <Cultist>();
            if (cultist.IsBeast && TriggerEntered)
            {
                TriggerEntered = false;
                Debug.Log("SIGNAL!");
                source.PlayOneShot(source.clip);

                farmer.SetIsHunting(true, cultist.transform.position);
            }
        }
    }
Beispiel #12
0
    // Use this for initialization
    void Awake()
    {
        if (autoFillCultists)
        {
            AllCultists = new List <Cultist>();
            GameObject cultistsParents = transform.Find("Cultists").gameObject;

            for (int i = 0; i < cultistsParents.transform.childCount; i++)
            {
                Cultist currentCultist = cultistsParents.transform.GetChild(i).GetComponent <Cultist>();
                AllCultists.Add(currentCultist);
                //   currentCultist.init(this);
            }
        }
    }
Beispiel #13
0
        public static void Test_WildStrike_FightNode()
        {
            var player = new Player(drawAmount: 1);
            var enemy  = new Cultist(40, 40);
            var cis    = GetCis("Strike", "WildStrike");
            var deck   = new Deck(cis);
            var mc     = new MonteCarlo(deck, enemy, player, firstHand: gsl("WildStrike"));
            //testing: this should create one choice with the first draw (which is force)

            var root = mc.SimAfterFirstDraw(100);
            //this should create root C=> draw => Cwildstrike => [R,various keys with no duplication]
            var a = 43;
            //TODO fix this.
            //structure should be: root => 1 draw => play ws => 2 randoms for where the wound ended up.
        }
Beispiel #14
0
        public void Test_Cultist()
        {
            var       player    = new Player(relics: GetRelics("Torii", "LetterOpener"));
            var       enemy     = new Cultist(60, 60);
            var       cis       = GetCis("Rage", "Defend", "Defend", "Bash", "FlameBarrier", "TwinStrike", "SeeingRed", "Pummel");
            var       deck      = new Deck(cis);
            var       mc        = new MonteCarlo(deck, enemy, player);
            var       histories = new List <double>();
            FightNode root;

            //can there ever be decreasing values? yes, when we re-explore a random draw and get a worse result.
            //that's too bad.
            for (var ii = 0; ii < 100; ii++)
            {
                root = mc.SimIncludingDraw(100);
                histories.Add(root.Value.Value);
            }
            Assert.IsTrue(histories.First() < histories.Last());
        }
Beispiel #15
0
        public void Test_LookForBugs()
        {
            var       player    = new Player(relics: GetRelics("Torii", "LetterOpener", "MonkeyPaw", "FusionHammer", "Vajra"));
            var       enemy     = new Cultist(70, 70);
            var       cis       = GetCis("Rage", "Defend", "Defend", "Bash", "FlameBarrier", "Dazed", "Shockwave", "ShrugItOff", "Inflame", "Inflame", "TwinStrike", "SeeingRed", "Pummel", "FeelNoPain", "RecklessCharge");
            var       deck      = new Deck(cis);
            var       mc        = new MonteCarlo(deck, enemy, player);
            var       histories = new List <double>();
            FightNode root;

            //can there ever be decreasing values? yes, when we re-explore a random draw and get a worse result.
            //that's too bad.
            for (var ii = 0; ii < 10; ii++)
            {
                root = mc.SimIncludingDraw(100);
                histories.Add(root.Value.Value);
            }
            Assert.IsTrue(histories.First() == 100 || histories.First() < histories.Last());
        }
Beispiel #16
0
        public static void Test_StrikePlusImprovesResult()
        {
            //generally weights are very very low later on even though state is similar.
            var hp = 80;

            var       player    = new Player();
            var       enemy     = new Cultist(hp, hp);
            var       cis       = GetCis("Bash", "Defend", "Strike", "Defend", "Strike", "Strike");
            var       deck      = new Deck(cis);
            var       mc        = new MonteCarlo(deck, enemy, player);
            var       histories = new List <double>();
            FightNode root;

            //can there ever be decreasing values? yes, when we re-explore a random draw and get a worse result.
            //that's too bad.
            for (var ii = 0; ii < 10; ii++)
            {
                root = mc.SimIncludingDraw(1000);
                histories.Add(root.Value.Value);
            }
            Assert.IsTrue(histories.First() < histories.Last());

            var       player2    = new Player();
            var       enemy2     = new Cultist(hp, hp);
            var       cis2       = GetCis("Bash", "Defend", "Strike+", "Defend", "Strike", "Strike");
            var       deck2      = new Deck(cis2);
            var       mc2        = new MonteCarlo(deck2, enemy2, player2);
            var       histories2 = new List <double>();
            FightNode root2;

            //can there ever be decreasing values? yes, when we re-explore a random draw and get a worse result.
            //that's too bad.
            for (var ii = 0; ii < 10; ii++)
            {
                root2 = mc2.SimIncludingDraw(1000);
                histories2.Add(root2.Value.Value);
            }
            Assert.IsTrue(histories2.First() < histories2.Last());

            //this is an improved deck
            Assert.IsTrue(histories.Last() < histories2.Last());
        }
Beispiel #17
0
    private void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.tag == "cultist")
        {
            Cultist cultist = col.gameObject.GetComponent <Cultist>();
            if (cultist.IsBeast)
            {
                //_agent.speed = 11;


                //Couroutine To Play Death Animation

                cultist.IsDying             = true;
                cultist._rigidbody.velocity = Vector3.zero;
                cultist.IsBeast             = false;
                //cultist.Marker.sprite = null;
                if (cultist.IsKilling)
                {
                    Piglet piglet = cultist._touchedPiglet;
                    piglet.Rb.velocity =
                        new Vector3(Random.Range(-1f, 1f), 0, Random.Range(-1f, 1f)).normalized *piglet._vel;
                    piglet.Rb.drag = 0;
                    foreach (TextMeshProUGUI txt in cultist.Text)
                    {
                        txt.text = "";
                    }

                    foreach (Animator animator in cultist.ButtonAnimators)
                    {
                        animator.SetBool("Active", false);
                    }
                }
                StartCoroutine(cultist.PlayDeathAnimation());
            }
            //  }
            // --
            //else
            // Load Win screen scene
        }
    }
Beispiel #18
0
 public StateSleep(Cultist connectedCultist) : base(connectedCultist)
 {
 }
	} //End.SendActionMessage()

	// Use this for initialization
	void Start()
	{
		IRC = this.GetComponent<TwitchIRC>();
		cultistGO = GameObject.Find ("Cultist");
		if (cultistGO)
			cultist = cultistGO.GetComponent<Cultist>();
		//IRC.SendCommand("CAP REQ :twitch.tv/tags"); //register for additional data such as emote-ids, name color etc.
		IRC.messageRecievedEvent.AddListener(OnChatMsgReceived);

		IRC.SendMsg ("!moobot poll close");
		string votes = "";
		foreach (string vote in voteOptions) {
			votes = votes + " " + vote;
		}
		IRC.SendMsg ("!moobot poll open w, s, a, d");
		InvokeRepeating ("PollResults", timer, timer);
	} //End.Start()
	} //End.PollReset()

	public void SetCultist() {
		if (cultistGO)
			cultist = cultistGO.GetComponent<Cultist> ();
		else {
			cultistGO = GameObject.Find ("Cultist");
			if (cultistGO)
				cultist = cultistGO.GetComponent<Cultist> ();
			else
				Debug.LogWarning ("Cultist not found.");
		}
			
	} //End.SetCultist()
Beispiel #21
0
 public State(Cultist connectedCultist)
 {
     cultist = connectedCultist;
 }
Beispiel #22
0
 public StateWork(Cultist connectedCultist) : base(connectedCultist)
 {
 }
Beispiel #23
0
 public StateIdle(Cultist connectedCultist) : base(connectedCultist)
 {
 }
    protected override void UnitUpdate()
    {
        //Search out for the enemy!
        Tile tile = GetComponentInParent <Tile>();

        if (terrified)
        {
            if (this.hometile.coord == tile.coord)
            {
                terrified = false;
            }
            else
            {
                MoveUnit(this.hometile.coord - tile.coord);
            }
            return;
        }

        GridManager grid    = this.transform.root.GetComponent <GridManager>();
        Cultist     cultist = tile.GetComponentInChildren <Cultist>();

        if (enemyLocation != tile.coord && (tile is SacrificialChamber || cultist != null))
        {
            //OH SHIT
            enemyLocation = tile.coord;
            //Play FOUND sound or whatever
            return;
        }
        Vector2Int moveDir = new Vector2Int(0, 0);

        if (grid.IsValidTile(enemyLocation))
        {
            if (castleLocation == tile.coord)
            {
                //We are at the castle!
                Knight knight = tile.GetComponentInChildren <Knight>();
                if (knight != null)
                {
                    knight.enemyLocation = enemyLocation;
                }
                else
                {
                    //Uhh?
                    Debug.Log("Inquisitor At castle but no knights!");
                }
                enemyLocation.Set(-1, -1);
                castleLocation.Set(-1, -1);
                return;
            }
            else
            {
                if (!grid.IsValidTile(castleLocation))
                {
                    Castle closestCastle = LocateClosestGridEntity <Castle>();
                    if (closestCastle != default(Castle))
                    {
                        castleLocation = closestCastle.coord;
                    }
                }

                //Move towards the castle!
                moveDir = castleLocation - tile.coord;
            }
        }
        else
        {
            Cultist closestCultist = LocateClosestGridEntity <Cultist>(2);
            if (closestCultist != default(Cultist))
            {
                moveDir = closestCultist.GetComponentInParent <Tile>().coord - tile.coord;
            }
        }

        if (moveDir.magnitude == 0)
        {
            if (curWanderTime > this.wanderTime)
            {
                MoveUnit(this.hometile.coord - tile.coord);
                if (this.hometile.coord == tile.coord)
                {
                    //Made it home, start wandering again.
                    curWanderTime = 0;
                }
            }
            else
            {
                MoveUnitRandom();
                curWanderTime++;
            }
        }
        else
        {
            MoveUnit(moveDir);
        }
    }
Beispiel #25
0
    public void TileClicked(Tile tile)
    {
        //Depending on your mode it will do different stuff.
        if (curUserState == UserStates.cultist)
        {
            //Okay!
            SpawnCultist(tile);
            PlayCastClip();
        }
        else if (curUserState == UserStates.knight)
        {
            //Was used for debugging
        }
        else if (curUserState == UserStates.cultist_taskmaster)
        {
            Cultist tileCultist = tile.GetComponentInChildren <Cultist>();

            if (!tileCultist)
            {
                if (mana >= taskmasterCost + cultistCost)
                {
                    DeltaMana(-(taskmasterCost + cultistCost));
                }
                else
                {
                    NotEnoughMana();
                    return;
                }
                tileCultist = SpawnCultist(tile);
                tileCultist.UpdateLeader(Cultist.LeaderState.taskmaster);
                PlayCastClip();
            }
            else if (tileCultist.curLeaderState != Cultist.LeaderState.taskmaster)
            {
                if (mana >= taskmasterCost)
                {
                    DeltaMana(-taskmasterCost);
                }
                else
                {
                    NotEnoughMana();
                    return;
                }
                tileCultist.UpdateLeader(Cultist.LeaderState.taskmaster);
                PlayCastClip();
            }
            else
            {
                tileCultist.UpdateLeader(Cultist.LeaderState.taskmaster);
            }
        }
        else if (curUserState == UserStates.necromancer)
        {
            Cultist tileCultist = tile.GetComponentInChildren <Cultist>();

            if (!tileCultist)
            {
                if (mana >= necroCost + cultistCost)
                {
                    DeltaMana(-(necroCost + cultistCost));
                }
                else
                {
                    NotEnoughMana();
                    return;
                }
                tileCultist = SpawnCultist(tile);
                tileCultist.UpdateLeader(Cultist.LeaderState.necromancer);
                PlayCastClip();
            }
            else if (tileCultist.curLeaderState != Cultist.LeaderState.necromancer)
            {
                if (mana >= necroCost)
                {
                    DeltaMana(-necroCost);
                }
                else
                {
                    NotEnoughMana();
                    return;
                }
                tileCultist.UpdateLeader(Cultist.LeaderState.necromancer);
                PlayCastClip();
            }
        }
        else if (curUserState == UserStates.succubus)
        {
            if (mana >= necroCost)
            {
                DeltaMana(-necroCost);
            }
            else
            {
                NotEnoughMana();
                return;
            }
            Succubus tileSuccubus = tile.CreateUnit <Succubus>(succubus);
            PlayCastClip();
        }
        else if (curUserState == UserStates.ghost)
        {
            if (mana >= ghostCost)
            {
                DeltaMana(-ghostCost);
            }
            else
            {
                NotEnoughMana();
                return;
            }
            Ghost tileGhost = tile.CreateUnit <Ghost>(ghost);
            PlayCastClip();
        }
    }
Beispiel #26
0
 public StateEat(Cultist connectedCultist) : base(connectedCultist)
 {
 }
    protected override void UnitUpdate()
    {
        //Do your stuff here


        //First combat (part of move timer?)
        Tile tile = GetComponentInParent <Tile>();

        if (terrified)
        {
            if (this.hometile.coord == tile.coord)
            {
                terrified = false;
            }
            else
            {
                MoveUnit(this.hometile.coord - tile.coord);
            }
            return;
        }

        GridManager grid    = this.transform.root.GetComponent <GridManager>();
        Cultist     cultist = tile.GetComponentInChildren <Cultist>();
        Zombie      zombie  = tile.GetComponentInChildren <Zombie>();
        Victim      victim  = tile.GetComponentInChildren <Victim>();

        if (cultist != null)
        {
            Debug.Log("MORTAL COMMBAAAAT C");
            //MORTAL COMBAAAAT
            cultist.LoseHealth(1);
            LoseHealth(1);
        }
        else if (zombie != null)
        {
            Debug.Log("MORTAL COMMBAAAAT Z");
            //MORTAL COMBAAAAT
            zombie.LoseHealth(1);
            LoseHealth(1);
        }
        else if (victim != null)
        {
            //Free the victims from their oppressors!
            victim.LoseHealth(1);
        }
        else
        {
            //No combat or victims to save.
            //First:  Think with your pants.
            Succubus foundSuccubus = LocateClosestGridEntity <Succubus>(1);
            if (foundSuccubus != null)
            {
                //Hey there cute stuff
                MoveUnit(foundSuccubus.GetComponentInParent <Tile>().coord - tile.coord);
            }
            else if (grid.IsValidTile(enemyLocation))
            {
                //Check if we have an alert
                if (enemyLocation == tile.coord)
                {
                    //Set it to null, we got to the point.
                    enemyLocation.Set(-1, -1);
                }
                else
                {
                    MoveUnit(enemyLocation - tile.coord);
                }
            }
            else
            {
                Cultist foundCultist = LocateClosestGridEntity <Cultist>(1);
                if (foundCultist != null)
                {
                    //WE FOUND A CULTIST, F**K EM UP
                    Debug.Log("FOUND A CULTIST, GET EM");
                    MoveUnit(foundCultist.GetComponentInParent <Tile>().coord - tile.coord);
                }
                else if (!(tile is Castle))
                {
                    //We arn't on a castle, and there is nothing else to do.

                    //Go home
                    MoveUnit(this.hometile.coord - tile.coord);
                }
            }
        }
    }