Ejemplo n.º 1
0
        public static void GettingStats(HeroClassTypes heroClass)
        {
            switch (heroClass)
            {
            case HeroClassTypes.spearman:
                Spearman spearman = new Spearman("Spearman", Alignment.good);
                Console.WriteLine($"Class Type : {spearman.Name}");
                Console.WriteLine($"Health : {spearman.Health}");
                Console.WriteLine($"Strength : {spearman.Strength}");
                Console.WriteLine($"Dexterity : {spearman.Dexterity}");
                Console.WriteLine($"Defence : {spearman.Defence}");
                break;

            case HeroClassTypes.swordsman:
                Swordsman swordsman = new Swordsman("Swordsman", Alignment.good);
                Console.WriteLine($"Class Type : {swordsman.Name}");
                Console.WriteLine($"Health : {swordsman.Health}");
                Console.WriteLine($"Strength : {swordsman.Strength}");
                Console.WriteLine($"Dexterity : {swordsman.Dexterity}");
                Console.WriteLine($"Defence : {swordsman.Defence}");
                break;

            case HeroClassTypes.ranger:
                Ranger ranger = new Ranger("Ranger", Alignment.good);
                Console.WriteLine($"Class Type : {ranger.Name}");
                Console.WriteLine($"Health : {ranger.Health}");
                Console.WriteLine($"Strength : {ranger.Strength}");
                Console.WriteLine($"Dexterity : {ranger.Dexterity}");
                Console.WriteLine($"Defence : {ranger.Defence}");
                break;

            default:
                break;
            }
        }
Ejemplo n.º 2
0
    void fire(Spearman.Args args)
    {
        this.power = args.power;

        Physics.IgnoreCollision(GetComponent<Collider>(), args.col);
        GetComponent<Rigidbody>().AddRelativeForce(Vector3.forward * power);
        transform.Rotate(90,0,0);
    }
Ejemplo n.º 3
0
 private void SpawnEnemies(CollisionDetection coldetect, ITransform hero)
 {
     foreach (var o in map.ObjectGroups[3].Objects)
     {
         Enemy temp = new Spearman(coldetect, new AIReader(hero));
         temp.Spawn(new Vector2((float)o.X, (float)o.Y));
         enemies.Add(temp);
     }
 }
        /// <summary>
        /// Handles the client.
        /// Receives data from the client and calculates the Spearman coefficient. Sends it to the client.
        /// </summary>
        public void Handle()
        {
            this.stream = client.GetStream();
            reader      = new StreamReader(stream);
            writer      = new StreamWriter(stream);

            int[][] query    = MakeArr(this.Recieve());
            string  username = this.Recieve();

            Spearman spearman   = new Spearman(query[0], query[1]);
            string   conclusion = spearman.Conclusion();

            this.Send(conclusion);
            this.Close();

            this.InsertToDB(username, spearman.Result, conclusion, query);
        }
Ejemplo n.º 5
0
        private void scriptMyselfFightToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string totalText = "Hoplites: " + Hoplite.ToString() + "\n";

            totalText += "Steam giants: " + SteamGiant.ToString() + "\n";
            totalText += "Spearmen: " + Spearman.ToString() + "\n";
            totalText += "Slingers: " + Slinger.ToString() + "\n";
            totalText += "Swordsmen: " + Swordsman.ToString() + "\n";
            totalText += "Archers: " + Archer.ToString() + "\n";
            totalText += "Sulphur carabineers: " + SulphurCarabineer.ToString() + "\n";
            totalText += "Rams: " + Ram.ToString() + "\n";
            totalText += "Catapults: " + Catapult.ToString() + "\n";
            totalText += "Mortars: " + Mortar.ToString() + "\n";
            totalText += "Gyrocopters: " + Gyrocopter.ToString() + "\n";
            totalText += "Balloon bombardiers: " + BalloonBombardier.ToString() + "\n";
            totalText += "Cooks: " + Cook.ToString() + "\n";
            totalText += "Doctors: " + Doctor.ToString() + "\n";
            totalText += "Transporter ships: " + TransporterShips.ToString() + "\n";
            totalText += "\nWhen finished, go to the city and press \"Raid\"";
            MessageBox.Show(totalText, "Auto fight");
        }
Ejemplo n.º 6
0
        public Order(Village village, string name, int quantity = 1)
        {
            id           = GetId();
            headquarters = new Headquarters();
            timberCamp   = new TimberCamp();
            clayPit      = new ClayPit();
            ironMine     = new IronMine();
            farm         = new Farm();
            warehouse    = new Warehouse();
            rallyPoint   = new RallyPoint();
            barracks     = new Barracks();
            statue       = new Statue();
            wall         = new Wall();
            hospital     = new Hospital();
            market       = new Market();
            tavern       = new Tavern();
            academy      = new Academy();
            hallOfOrders = new HallOfOrders();

            spearman      = new Spearman();
            swordsman     = new Swordsman();
            archer        = new Archer();
            heavyCavalry  = new HeavyCavalry();
            axeFighter    = new AxeFighter();
            lightCavalry  = new LightCavalry();
            mountedArcher = new MountedArcher();
            ram           = new Ram();
            catapult      = new Catapult();


            barracksInfos      = new List <PartialBarracksInfo>();
            farmInfos          = new List <PartialFarmInfo>();
            waitInfos          = new List <PartialWaitInfo>();
            barracksToDateTime = new Dictionary <int, DateTime>();
            stringToEntity     = new Dictionary <string, Entity>()
            {
                { "Headquarters", headquarters },
                { "TimberCamp", timberCamp },
                { "ClayPit", clayPit },
                { "IronMine", ironMine },
                { "Farm", farm },
                { "Warehouse", warehouse },
                { "RallyPoint", rallyPoint },
                { "Barracks", barracks },
                { "Statue", statue },
                { "Wall", wall },
                { "Hospital", hospital },
                { "Market", market },
                { "Tavern", tavern },
                { "Academy", academy },
                { "HallOfOrders", hallOfOrders },

                { "Spearman", spearman },
                { "Swordsman", swordsman },
                { "Archer", archer },
                { "HeavyCavalry", heavyCavalry },
                { "AxeFighter", axeFighter },
                { "LightCavalry", lightCavalry },
                { "MountedArcher", mountedArcher },
                { "Ram", ram },
                { "Catapult", catapult },

                { "init", null }
            };
            barracksToLimit = new Dictionary <int, int>()
            {
                { 1, 5 },
                { 2, 10 },
                { 3, 15 }
            };
            for (int i = 4; i <= 25; i++)
            {
                barracksToLimit.Add(i, int.MaxValue);
            }
            this.name     = name;
            this.quantity = quantity;
            entity        = stringToEntity[name];
            bar           = new OrderBar(this.village = village);
        }
Ejemplo n.º 7
0
    private void loadEntities(string entitiesPath)
    {
        System.IO.StreamReader file = new System.IO.StreamReader(entitiesPath);
        if (file != null)
        {
            for (int i = 0; i < _mapHeight; i++)
            {
                string a = file.ReadLine();
                int    x = 0;
                foreach (char c in a)
                {
                    _entitiesData[x, i] = c;
                    x++;
                    if (x == 64)
                    {
                        break;
                    }
                }
            }
            file.Close();
        }

        Player = new Player(this);

        for (int i = 0; i < _mapWidth; i++)
        {
            for (int j = 0; j < _mapHeight; j++)
            {
                switch (_entitiesData[i, j])
                {
                case 't':     // tree
                    Tree tree = new Tree(this, new Vector2(i * data.tSize(), j * data.tSize()));
                    entities.Add(tree);
                    break;

                case 'm':     //mine
                    Mine mine = new Mine(this, new Vector2(i * data.tSize(), j * data.tSize()));
                    entities.Add(mine);
                    break;

                case 's':     //human stronghold/townhall
                    Townhall hTownhall = new Townhall(this, new Vector2(i * data.tSize(), j * data.tSize()), BuildingAndUnit.faction.Human);
                    entities.Add(hTownhall);
                    break;

                case 'S':     //orc stronghold/townhall
                    Townhall oTownhall = new Townhall(this, new Vector2(i * data.tSize(), j * data.tSize()), BuildingAndUnit.faction.Orc);
                    entities.Add(oTownhall);
                    break;

                case 'f':     //human farm
                    Farm hFarm = new Farm(this, new Vector2(i * data.tSize(), j * data.tSize()), BuildingAndUnit.faction.Human);
                    entities.Add(hFarm);
                    break;

                case 'F':     // orc farm
                    Farm oFarm = new Farm(this, new Vector2(i * data.tSize(), j * data.tSize()), BuildingAndUnit.faction.Orc);
                    entities.Add(oFarm);
                    break;

                case 'b':     //human barracks
                    Barracks hBarracks = new Barracks(this, new Vector2(i * data.tSize(), j * data.tSize()), BuildingAndUnit.faction.Human);
                    entities.Add(hBarracks);
                    break;

                case 'B':     //orc barracks
                    Barracks oBarracks = new Barracks(this, new Vector2(i * data.tSize(), j * data.tSize()), BuildingAndUnit.faction.Orc);
                    entities.Add(oBarracks);
                    break;

                default:
                    break;
                }
            }
        }
        for (int i = 0; i < _mapWidth; i++)
        {
            for (int j = 0; j < _mapHeight; j++)
            {
                switch (_entitiesData[i, j])
                {
                case 'g':     //footman
                    Footman footman = new Footman(this, new Vector2(i * data.tSize(), j * data.tSize()));
                    entities.Add(footman);
                    break;

                case 'G':     //grunt
                    Grunt grunt = new Grunt(this, new Vector2(i * data.tSize(), j * data.tSize()));
                    entities.Add(grunt);
                    break;

                case 'p':     //peasant
                    Peasant peasant = new Peasant(this, new Vector2(i * data.tSize(), j * data.tSize()));
                    entities.Add(peasant);
                    break;

                case 'P':     //peon
                    Peon peon = new Peon(this, new Vector2(i * data.tSize(), j * data.tSize()));
                    entities.Add(peon);
                    break;

                case 'a':     //archer
                    Archer archer = new Archer(this, new Vector2(i * data.tSize(), j * data.tSize()));
                    entities.Add(archer);
                    break;

                case 'A':     //spearman
                    Spearman spearman = new Spearman(this, new Vector2(i * data.tSize(), j * data.tSize()));
                    entities.Add(spearman);
                    break;

                default:
                    break;
                }
            }
        }
    }
Ejemplo n.º 8
0
    IEnumerator CalculateSpearman()
    {
        while (!_shouldStop)
        {
            _spearmanIsRunning = true;

            TimeSpan calcStart = new TimeSpan();
            calcStart = PupilGazeTracker.Instance._globalTime;

            List <MovingObject> _tempObjects = new List <MovingObject>();
            _cloningInProgress = true;
            foreach (MovingObject mo in sceneObjects)
            {
                _tempObjects.Add((MovingObject)mo.Clone());                                       //work on a copy to (hopefully) improve performance
            }
            MovingObject _tempGaze = (MovingObject)gazeTrajectory.Clone();
            _cloningInProgress = false;
            List <double> _tempXPgaze = new List <double>(_tempGaze.getXPoints());
            List <double> _tempYPgaze = new List <double>(_tempGaze.getYPoints());

            // write gaze points in logfile
            //foreach (double dx in _tempXPgaze) trajectoryWriter.WriteLine("gazex;" + calcStart.TotalSeconds + dx);
            //foreach (double dy in _tempYPgaze) trajectoryWriter.WriteLine("gazey;" + calcStart.TotalSeconds + dy);

            List <float> results = new List <float>();

            foreach (MovingObject mo in _tempObjects)
            {
                // temporary list for not having to generate a new one at every loop
                List <double> _tempXPObj = new List <double>(mo.getXPoints());
                List <double> _tempYPObj = new List <double>(mo.getYPoints());

                // write object coordinates to logfile
                //foreach (double dx in _tempXPObj) trajectoryWriter.WriteLine(mo.name + ";" + calcStart.TotalSeconds + dx);
                //foreach (double dy in _tempXPObj) trajectoryWriter.WriteLine(mo.name + ";" + calcStart.TotalSeconds + dy);

                // surround calculation with try/catch block or else coroutine will end if something is divided by zero
                try
                {
                    double coeffX = Spearman.calculateSpearman(_tempXPgaze, _tempXPObj);
                    double coeffY = Spearman.calculateSpearman(_tempYPgaze, _tempYPObj);

                    correlationWriter.WriteLine(mo.name + ";" + calcStart.TotalSeconds + ";" + coeffX + ";" + coeffY + ";" + w + ";" + corrWindow + ";" + corrFrequency + ";" + Coefficient + ";" + Gaze);

                    // add result to the MovingObject in the original list
                    results.Add((float)sceneObjects.Find(x => x.Equals(mo)).addSample(calcStart, (coeffX + coeffY) / 2, corrWindow));
                }
                catch (Exception e)
                {
                    Debug.LogError(e.StackTrace);
                }
            }

            //activate only one item at a time
            for (int i = 0; i < results.Count; i++)
            {
                // activate the object with the highest correlation value only if it's above threshold
                if (results[i].CompareTo(results.Max()) == 0 && results[i] > threshold / 2)
                {
                    _tempObjects[i].activate(true); //doesn't matter if original or clone list is used as both refer to the same GameObject
                }
                else
                {
                    _tempObjects[i].activate(false);
                }
            }

            calcDur = PupilGazeTracker.Instance._globalTime - calcStart;

            yield return(new WaitForSeconds(corrFrequency - (float)calcDur.TotalSeconds)); // calculation should take place every x seconds
        }
    }
Ejemplo n.º 9
0
    public static PlayerUnit create_punit(int ID, int owner_ID)
    {
        PlayerUnit pu = null;

        if (ID == WARRIOR)
        {
            pu = new Warrior();
        }
        else if (ID == SPEARMAN)
        {
            pu = new Spearman();
        }
        else if (ID == ARCHER)
        {
            pu = new Archer();
        }
        else if (ID == MINER)
        {
            pu = new Miner();
        }
        else if (ID == INSPIRATOR)
        {
            pu = new Inspirator();
        }
        else if (ID == SEEKER)
        {
            pu = new Seeker();
        }
        else if (ID == GUARDIAN)
        {
            pu = new Guardian();
        }
        else if (ID == ARBALEST)
        {
            pu = new Arbalest();
        }
        else if (ID == SKIRMISHER)
        {
            pu = new Skirmisher();
        }
        else if (ID == PALADIN)
        {
            pu = new Paladin();
        }
        else if (ID == MENDER)
        {
            pu = new Mender();
        }
        else if (ID == DRUMMER)
        {
            pu = new Drummer();
        }
        else if (ID == PIKEMAN)
        {
            pu = new Pikeman();
        }
        else if (ID == CARTER)
        {
            pu = new Carter();
        }
        else if (ID == DRAGOON)
        {
            pu = new Dragoon();
        }
        else if (ID == SCOUT)
        {
            pu = new Scout();
        }
        else if (ID == SHIELD_MAIDEN)
        {
            pu = new ShieldMaiden();
        }
        pu.owner_ID = owner_ID;
        return(pu);
    }