-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
05249e1
commit 156005e
Showing
40 changed files
with
2,300 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace ZooManager | ||
{ | ||
public class Animal | ||
{ | ||
public string emoji; | ||
public string species; | ||
public string name; | ||
public int reactionTime = 5; // default reaction time for animals (1 - 10) | ||
|
||
public Point location; | ||
|
||
/*public Dictionary<Direction, int> directionInfo = new Dictionary<Direction, int>(); | ||
public List<Direction> targetDirections = new List<Direction>();*/ | ||
|
||
public void ReportLocation() | ||
{ | ||
Console.WriteLine($"I am at {location.x},{location.y}"); | ||
} | ||
|
||
//virtual is used in parent class, so that the child can base on it and override it | ||
virtual public void Activate() | ||
{ | ||
Console.WriteLine($"Animal {name} at {location.x},{location.y} activated"); | ||
} | ||
virtual public void Hunt(List<string> targets, int distance) | ||
{ | ||
(Dictionary<Direction, int> directionInfo, List<Direction> targetDirections) = Game.Seek(location.x, location.y, targets, distance); | ||
if (targetDirections.Count > 0) | ||
{ | ||
Game.Attack(this, targetDirections[new Random().Next(0, targetDirections.Count)], distance); | ||
} | ||
} | ||
virtual public void Flee(List<string> targets, int distance) | ||
{ | ||
(Dictionary<Direction, int> directionInfo, List<Direction> targetDirections) = Game.Seek(location.x, location.y, targets, 1); | ||
if (targetDirections.Count > 0) | ||
{ | ||
(int movedCell, Direction? origDirection) = Game.Move(this, distance, null); | ||
int allMovedCell = movedCell; | ||
while (movedCell != 0 && distance - allMovedCell > 0) | ||
{ | ||
(movedCell, origDirection) = Game.Move(this, distance - allMovedCell, origDirection); | ||
allMovedCell += movedCell; | ||
} | ||
} | ||
/*foreach (var direction in targetDirections) | ||
{ | ||
if (direction == Direction.up) if (Game.Retreat(this, Direction.down, distance)) return; | ||
if (direction == Direction.down) if (Game.Retreat(this, Direction.up, distance)) return; | ||
if (direction == Direction.left) if (Game.Retreat(this, Direction.right, distance)) return; | ||
if (direction == Direction.right) if (Game.Retreat(this, Direction.left, distance)) return; | ||
}*/ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Router AppAssembly="@typeof(Program).Assembly" PreferExactMatches="@true"> | ||
<Found Context="routeData"> | ||
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" /> | ||
</Found> | ||
<NotFound> | ||
<LayoutView Layout="@typeof(MainLayout)"> | ||
<p>Sorry, there's nothing at this address.</p> | ||
</LayoutView> | ||
</NotFound> | ||
</Router> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.Xml.Linq; | ||
|
||
namespace ZooManager | ||
{ | ||
public class Bird : Animal | ||
{ | ||
public Bird(string animalName) | ||
{ | ||
species = "bird"; | ||
//"this" means this class, to seperate the arg of name | ||
//this.name = name; | ||
//we can also replace arg with "animalName" to do the same thing | ||
name = animalName; | ||
//should change this line in game | ||
//if (animalZones[y][x].occupant.species == target) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace ZooManager | ||
{ | ||
public class Cat : Animal | ||
{ | ||
public Cat(string name) | ||
{ | ||
emoji = "🐱"; | ||
species = "cat"; | ||
this.name = name; | ||
reactionTime = new Random().Next(1, 6); // reaction time 1 (fast) to 5 (medium) | ||
//reactionTime = 1; | ||
} | ||
|
||
//override the Activate() in Animal | ||
public override void Activate() | ||
{ | ||
//base is Animal | ||
base.Activate(); | ||
Console.WriteLine("I am a cat. Meow."); | ||
//hunt can runaway from a raptor, since it also move to the other cell | ||
Hunt(new List<string>() { "mouse", "chick" }, 1); | ||
Flee(new List<string>() { "raptor" }, 1); | ||
} | ||
|
||
/*public void Flee(List<string> targets) | ||
{ | ||
(Dictionary<Direction, int> directionInfo, List<Direction> targetDirections) = Game.Seek(location.x, location.y, targets, 1); | ||
foreach (var direction in targetDirections) | ||
{ | ||
if (direction == Direction.up) if (Game.Retreat(this, Direction.down)) return; | ||
if (direction == Direction.down) if (Game.Retreat(this, Direction.up)) return; | ||
if (direction == Direction.left) if (Game.Retreat(this, Direction.right)) return; | ||
if (direction == Direction.right) if (Game.Retreat(this, Direction.left)) return; | ||
}*/ | ||
|
||
//checking all the directions, if found cat (ture), then run away from that direction (change the cell) | ||
/*if (Game.Seek(location.x, location.y, Direction.up, "raptor")) | ||
{ | ||
if (Game.Retreat(this, Direction.down)) return; | ||
} | ||
if (Game.Seek(location.x, location.y, Direction.down, "raptor")) | ||
{ | ||
if (Game.Retreat(this, Direction.up)) return; | ||
} | ||
if (Game.Seek(location.x, location.y, Direction.left, "raptor")) | ||
{ | ||
if (Game.Retreat(this, Direction.right)) return; | ||
} | ||
if (Game.Seek(location.x, location.y, Direction.right, "raptor")) | ||
{ | ||
if (Game.Retreat(this, Direction.left)) return; | ||
}*/ | ||
//} | ||
|
||
/* Note that our cat is currently not very clever about its hunting. | ||
It will always try to attack "up" and will only seek "down" if there | ||
is no mouse above it. This does not affect the cat's effectiveness | ||
very much, since the overall logic here is "look around for a mouse and | ||
attack the first one you see." This logic might be less sound once the | ||
cat also has a predator to avoid, since the cat may not want to run in | ||
to a square that sets it up to be attacked! | ||
请注意,我们的猫目前在捕猎方面不是很聪明。它总是试图攻击 "上面", | ||
只有在上面没有老鼠的情况下才会寻找 "下面"。这对猫的效率影响不大, | ||
因为这里的总体逻辑是 "四处寻找老鼠并攻击你看到的第一只老鼠"。 | ||
一旦猫有了要避开的捕食者,这个逻辑可能就不那么靠谱了, | ||
因为猫可能不想跑到一个为它设置了被攻击的方格中去!"。 | ||
*/ | ||
|
||
//if the cat's index is lower it can attack and flee | ||
/////public override void Hunt(List<string> targets) | ||
/////{ | ||
//base.Hunt(targets); | ||
/////(Dictionary<Direction, int> directionInfo, List<Direction> targetDirections) = Game.Seek(location.x, location.y, targets, 1); | ||
/*foreach (var direction in targetDirections) | ||
{ | ||
if (direction == Direction.up) Game.Attack(this, Direction.up); | ||
if (direction == Direction.down) Game.Attack(this, Direction.down); | ||
if (direction == Direction.left) Game.Attack(this, Direction.left); | ||
if (direction == Direction.right) Game.Attack(this, Direction.right); | ||
}*/ | ||
//Console.WriteLine("-----------------"+ new Random().Next(0, 0)); | ||
/////if (targetDirections.Count>0) | ||
/////{ | ||
/////Game.Attack(this, targetDirections[new Random().Next(0, targetDirections.Count)]); | ||
/////} | ||
//Game.Attack(this, targetDirections[0]); | ||
|
||
//this is concept for aovid eating an animal and then be eaten, but the way to seek is now different | ||
/*if ( | ||
!Game.Seek(location.x, location.y + 1, Direction.up, "raptor") && !Game.Seek(location.x, location.y + 1, Direction.left, "raptor") && !Game.Seek(location.x, location.y + 1, Direction.right, "raptor") && | ||
!Game.Seek(location.x, location.y - 1, Direction.down, "raptor") && !Game.Seek(location.x, location.y - 1, Direction.left, "raptor") && !Game.Seek(location.x, location.y - 1, Direction.right, "raptor") && | ||
!Game.Seek(location.x + 1, location.y, Direction.up, "raptor") && !Game.Seek(location.x + 1, location.y, Direction.down, "raptor") && !Game.Seek(location.x + 1, location.y, Direction.right, "raptor") && | ||
!Game.Seek(location.x - 1, location.y, Direction.up, "raptor") && !Game.Seek(location.x - 1, location.y, Direction.down, "raptor") && !Game.Seek(location.x - 1, location.y, Direction.left, "raptor") | ||
) | ||
{*/ | ||
|
||
//checking all the directions, if found cat (ture), then attack that direction (reaplce the cell) | ||
/*if (Game.Seek(location.x, location.y, Direction.up, "mouse") || Game.Seek(location.x, location.y, Direction.up, "chick")) | ||
{ | ||
Game.Attack(this, Direction.up); | ||
} | ||
else if (Game.Seek(location.x, location.y, Direction.down, "mouse") || Game.Seek(location.x, location.y, Direction.down, "chick")) | ||
{ | ||
Game.Attack(this, Direction.down); | ||
} | ||
else if (Game.Seek(location.x, location.y, Direction.left, "mouse") || Game.Seek(location.x, location.y, Direction.left, "chick")) | ||
{ | ||
Game.Attack(this, Direction.left); | ||
} | ||
else if (Game.Seek(location.x, location.y, Direction.right, "mouse") || Game.Seek(location.x, location.y, Direction.right, "chick")) | ||
{ | ||
Game.Attack(this, Direction.right); | ||
}*/ | ||
//} | ||
/////} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace ZooManager | ||
{ | ||
public class Chick : Bird | ||
{ | ||
//deliever the arg from bird to chick | ||
public Chick(string name) : base(name) | ||
{ | ||
emoji = "🐥"; | ||
//species = "bird"; | ||
//"this" means this class, to seperate the arg of name | ||
//this.name = name; | ||
//reaction time is 6 (<=6) to 10 (<11) | ||
reactionTime = new Random().Next(6, 11); | ||
//reactionTime = 1; | ||
} | ||
|
||
public override void Activate() | ||
{ | ||
//base is Bird -> Animal | ||
base.Activate(); | ||
Console.WriteLine("I am a chick."); | ||
Flee(new List<string>() { "cat" }, 1); | ||
} | ||
|
||
/*public void Flee(List<string> targets) | ||
{ | ||
(Dictionary<Direction, int> directionInfo, List<Direction> targetDirections) = Game.Seek(location.x, location.y, targets, 1); | ||
foreach (var direction in targetDirections) | ||
{ | ||
if (direction == Direction.up) if (Game.Retreat(this, Direction.down)) return; | ||
if (direction == Direction.down) if (Game.Retreat(this, Direction.up)) return; | ||
if (direction == Direction.left) if (Game.Retreat(this, Direction.right)) return; | ||
if (direction == Direction.right) if (Game.Retreat(this, Direction.left)) return; | ||
}*/ | ||
|
||
//checking all the directions, if found cat (ture), then run away from that direction (change the cell) | ||
/*if (Game.Seek(location.x, location.y, Direction.up, "cat")) | ||
{ | ||
if (Game.Retreat(this, Direction.down)) return; | ||
} | ||
if (Game.Seek(location.x, location.y, Direction.down, "cat")) | ||
{ | ||
if (Game.Retreat(this, Direction.up)) return; | ||
} | ||
if (Game.Seek(location.x, location.y, Direction.left, "cat")) | ||
{ | ||
if (Game.Retreat(this, Direction.right)) return; | ||
} | ||
if (Game.Seek(location.x, location.y, Direction.right, "cat")) | ||
{ | ||
if (Game.Retreat(this, Direction.left)) return; | ||
}*/ | ||
//} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
namespace ZooManager | ||
{ | ||
//enum is a class to store constants | ||
public enum Direction | ||
{ | ||
left, | ||
right, | ||
up, | ||
down | ||
} | ||
} | ||
|
Oops, something went wrong.