Ejemplo n.º 1
0
        public Client(ISettings settings, IApiFailureStrategy apiFailureStrategy)
        {
            Settings          = settings;
            ApiFailure        = apiFailureStrategy;
            Proxy             = InitProxy();
            PokemonHttpClient = new PokemonHttpClient();
            Login             = new Rpc.Login(this);
            Player            = new Player(this);
            Download          = new Download(this);
            Inventory         = new Inventory(this);
            Map       = new Map(this);
            Fort      = new Fort(this);
            Encounter = new Encounter(this);
            Misc      = new Misc(this);

            Player.SetCoordinates(Settings.DefaultLatitude, Settings.DefaultLongitude, Settings.DefaultAltitude);

            InventoryLastUpdateTimestamp = 0;

            Platform = settings.DevicePlatform.Equals("ios", StringComparison.Ordinal) ? Platform.Ios : Platform.Android;

            AppVersion   = 3500;
            SettingsHash = "";

            CurrentApiEmulationVersion = new Version("0.35.0");
        }
Ejemplo n.º 2
0
 /// <summary>
 /// To be called when a player believes the game is over
 /// </summary>
 /// <param name="fort">The player/Fort which throws the message</param>
 /// <param name="win">Whether ther player won or lost</param>
 private void OnWinLoseCondition(Fort fort, bool win)
 {
     if (_player1.CompareFort(fort))
     {
         if (win)
         {
             Debug.Log("Player 1 Won");
         }
         else
         {
             Debug.Log("Player 1 Lost");
         }
     }
     else
     {
         if (win)
         {
             Debug.Log("Player 2 Won");
         }
         else
         {
             Debug.Log("Player 2 Lost");
         }
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// To be called when a player believes the game is over
 /// </summary>
 /// <param name="fort">The player/Fort which throws the message</param>
 /// <param name="win">Whether ther player won or lost</param>
 private void OnWinLoseCondition(Fort fort, bool win)
 {
     if (_player1.CompareFort(fort))
     {
         if (win)
         {
             Debug.Log("Player 1 Won");
         }
         else
         {
             Debug.Log("Player 1 Lost");
         }
     }
     else
     {
         if (win)
         {
             Debug.Log("Player 2 Won");
         }
         else
         {
             Debug.Log("Player 2 Lost");
         }
     }
 }
Ejemplo n.º 4
0
    void OnGUI()
    {
        GUILayout.BeginArea(
            new Rect((Screen.width - width) / 2.0f, 0, width, height),
            GUI.skin.box
            );

        GUI.Label(
            new Rect(5, 3, 100, 25),
            String.Format("Villagers: {0} / {1}", villagerCount, SpawnVillagers.TotalVillagerCapacity()),
            CurrentCountSkin()
            );

        GUI.Label(new Rect(width - 150, 3, 150, 25), String.Format("Currently {0}", HutBuilding.CurrentStateDescriptor()));

        GUI.Label(
            new Rect(5, 28, 100, 25),
            String.Format("Orcs: {0} / {1}", Ork.AllOrks().Count(), Fort.TotalOrkCapacity())
            );

        GUI.Label(
            new Rect(width - 150, 28, 150, 25),
            String.Format("Time until next fort: {0}s", SpawnForts.TimeUntilNextSpawn())
            );

        GUI.Label(
            new Rect((width / 2f) - 35, 50, 80, 25),
            String.Format("Time: {0}", ProgressTracker.FormattedPlaytime())
            );

        GUILayout.EndArea();
    }
Ejemplo n.º 5
0
        public void DrawFort(Fort fort)
        {
            int size = 100;

            var circle = new Ellipse();

            circle.SetValue(Canvas.TopProperty, (double)(fort.Location.Y * SCALINGFACTOR));
            circle.SetValue(Canvas.LeftProperty, (double)(fort.Location.X * SCALINGFACTOR));
            circle.Height          = size;
            circle.Width           = circle.Height;
            circle.StrokeThickness = 2;
            if (fort.FortOwner == null)
            {
                circle.Stroke = Brushes.Black;
            }
            else
            {
                circle.Stroke = m_playerColorMapping[fort.FortOwner];
            }
            Canvas.Children.Add(circle);

            DrawText((fort.Location.X) * SCALINGFACTOR, (fort.Location.Y) * SCALINGFACTOR - 45, "BirthType: " + fort.BirthingType.ToString(), Colors.Black);
            DrawText((fort.Location.X) * SCALINGFACTOR, (fort.Location.Y) * SCALINGFACTOR - 15, "BirthRate: " + fort.BirthSpeed.ToString(), Colors.Black);
            DrawText((fort.Location.X) * SCALINGFACTOR, (fort.Location.Y) * SCALINGFACTOR - 30, "Owner: " + fort.FortOwner, Colors.Black);
            DrawText((fort.Location.X) * SCALINGFACTOR + size / 4, (fort.Location.Y) * SCALINGFACTOR + size / 4, "->: " + fort.DefendingGuys.Sum(g => g.Strength).ToString(), Colors.Black);
            DrawText((fort.Location.X) * SCALINGFACTOR + size / 4, (fort.Location.Y) * SCALINGFACTOR + size / 4 + 15, "+: " + fort.DefendingGuys.Sum(g => g.Health).ToString(), Colors.Black);
        }
Ejemplo n.º 6
0
    void FixedUpdate()
    {
        if (!lockMonster)
        {
            return;
        }
        if (lockMonster.getHp() <= 0)
        {
            return;
        }

        if (Vector3.Distance(lockMonster.transform.position, transform.position) > searchRadius)
        {
            return;
        }
        // 根據等級取得目前砲台資料
        Fort fort = fort_list[level];

        Vector3 targetDir = lockMonster.transform.position - fort.transform.position;
        Vector3 newDir    = Vector3.RotateTowards(fort.transform.forward, targetDir, 0.05F, 0.0F);

        if (!BulletType.Equals("tesla"))
        {
            fort.transform.rotation = Quaternion.LookRotation(newDir);
            if (bullet != null)
            {
                bullet.SetRotation(Quaternion.LookRotation(newDir));
            }
        }
    }
Ejemplo n.º 7
0
        public virtual async Task <Fort> UpdateOneAsync(Fort item, bool updateDate = true)
        {
            try
            {
                if (string.IsNullOrEmpty(item.Id))
                {
                    item.Id          = ObjectId.GenerateNewId().ToString();
                    item.CreatedDate = DateTime.UtcNow;
                    item.UpdatedDate = DateTime.UtcNow;
                    await _context.Fort.InsertOneAsync(item);
                }
                else
                {
                    item.UpdatedDate = DateTime.UtcNow;
                }

                var filter = Builders <Fort> .Filter.Eq(s => s.Id, item.Id);

                await _context.Fort.ReplaceOneAsync(filter, item, new UpdateOptions { IsUpsert = true });


                return(item);
            }
            catch (Exception ex)
            {
                // log or manage the exception
                throw ex;
            }
        }
        public string GetProductGP(string curLocale)
        {
            int    curRow = (curLocale[0] - 'A');
            int    curCol = 0;
            double dist = 0.0,
                   minDist = double.MaxValue - 1;
            Fort junk, minDistFort = null;

            int.TryParse(curLocale.Substring(1), out curCol);
            Dictionary <double, Fort> distances = new Dictionary <double, Fort>();

            foreach (Fort poss in forts)
            {
                dist = Math.Sqrt(Math.Pow((poss.row - curRow), 2) + Math.Pow((poss.col - curCol), 2));
                if (dist < minDist)
                {
                    minDist     = dist;
                    minDistFort = poss;
                }
                if (!distances.TryGetValue(dist, out junk))
                {
                    distances.Add(dist, poss);
                }
            }

            return(minDistFort.name + " - " + minDistFort.fullRowCol);
        }
Ejemplo n.º 9
0
 public GuyGroup(Fort destinationFort, int numGuys, Point currentLocation, Player owner)
 {
     DestinationFort   = destinationFort;
     NumGuys           = numGuys;
     TicksTillFinished = (int)currentLocation.GetDistanceTo(destinationFort.Location);
     GroupOwner        = owner;
     InstanceID        = InstanceCounter++;
 }
Ejemplo n.º 10
0
 public static Fort GetInstance()
 {
     if (instance == null)
     {
         instance = GameObject.Find("Fort").GetComponent <Fort>();
     }
     return(instance);
 }
Ejemplo n.º 11
0
 //this initializes before start
 void Awake()
 {
     fort = fortObj.GetComponent<Fort>();
     player = playerObj.GetComponent<PlayerController>();
     player.team = this;
     fort.team = this;
     score = scoreObj.GetComponent<GUIText>();
     altar = altarObj.GetComponent<SacrificialAltar>();
 }
Ejemplo n.º 12
0
 //this initializes before start
 void Awake()
 {
     fort        = fortObj.GetComponent <Fort>();
     player      = playerObj.GetComponent <PlayerController>();
     player.team = this;
     fort.team   = this;
     score       = scoreObj.GetComponent <GUIText>();
     altar       = altarObj.GetComponent <SacrificialAltar>();
 }
Ejemplo n.º 13
0
    private void spawnFort()
    {
        TopTile tile = (TopTile)TileData.hash[inputHandler.clickedTile];

        if (tile.ownerId == -1)
        {
            Fort fort = new Fort(tile.tileObject.transform.position, fortModel, tile.x, tile.y);
            selectTeritory(fort);
        }
    }
Ejemplo n.º 14
0
    // Start is called before the first frame update
    void Start()
    {
        animator  = GetComponent <Animator>();
        trashcan  = FindObjectOfType <Trashcan>();
        fort      = FindObjectOfType <Fort>();
        bookshelf = FindObjectOfType <Bookshelf>();

        // Register this object for pause/unpause updates
        SceneDirector.GetPrimary().Register(this);
    }
Ejemplo n.º 15
0
 public static List <Move> MoveAll(Fort srcFort, Fort destFort)
 {
     return(new List <Move>
     {
         MoveAverage(srcFort, destFort, FilterAverage(srcFort.DefendingGuys).Count),
         MoveArmored(srcFort, destFort, FilterArmored(srcFort.DefendingGuys).Count),
         MoveBeefy(srcFort, destFort, FilterBeefy(srcFort.DefendingGuys).Count),
         MoveRunner(srcFort, destFort, FilterRunner(srcFort.DefendingGuys).Count)
     });
 }
Ejemplo n.º 16
0
        public GuyGroup SendGuyGroup(Fort destination, int numGuys)
        {
            if (destination == this || numGuys > NumDefendingGuys)
            {
                return(null);
            }

            NumDefendingGuys -= numGuys;

            return(new GuyGroup(destination, numGuys, Location, FortOwner));
        }
Ejemplo n.º 17
0
 void Awake()
 {
     killedOrks = new HashSet <Ork>();
     Hut.ResetAll();
     Fort.ResetAll();
     Villager.ResetAll();
     Ork.ResetAll();
     SecondsOfPlay        = 0;
     villagersHaveSpawned = false;
     FireBreathed         = 0f;
 }
Ejemplo n.º 18
0
        public static object[] GetWinnerTestCases()
        {
            Player p1 = new Player {
                Name = "player1"
            };
            Player p2 = new Player {
                Name = "player2"
            };

            Fort fort1 = new Fort();
            Fort fort2 = new Fort();

            Fort p1Fort1 = new Fort {
                FortOwner = p1
            };
            Fort p1Fort2 = new Fort {
                FortOwner = p1
            };
            Fort p1Fort3 = new Fort {
                FortOwner = p1
            };

            Fort p2Fort1 = new Fort {
                FortOwner = p2
            };
            Fort p2Fort2 = new Fort {
                FortOwner = p2
            };

            return(new object[]
            {
                new object[] { new List <Fort> {
                                   p1Fort1, p1Fort2, p1Fort3, fort1, fort2
                               }, p1 },
                new object[] { new List <Fort> {
                                   p1Fort1, p1Fort2, p1Fort3
                               }, p1 },
                new object[] { new List <Fort> {
                                   p2Fort1, fort1, fort2
                               }, p2 },
                new object[] { new List <Fort> {
                                   fort1, fort2
                               }, null },
                new object[] { new List <Fort> {
                                   p1Fort1, p1Fort2, p2Fort1, fort1, fort2
                               }, null },
                new object[] { new List <Fort> {
                                   p1Fort1, p1Fort2, p2Fort1, p2Fort2, fort1, fort2
                               }, null },
                new object[] { new List <Fort>(), null }
            });
        }
Ejemplo n.º 19
0
        public override List <Move> Do(string boardString)
        {
            var board = JsonConvert.DeserializeObject <BoardState>(boardString);

            var friendlyForts = GetFriendlyForts(board);
            var enemyForts    = GetEnemyForts(board);
            var neutralForts  = GetNeutralForts(board);

            var moves = new List <Move>();

            Fort runnersFort = null;

            Fort weakestEnemy = enemyForts[0];

            // find closest weak enemy and stockpile until can beat
            foreach (var fort in enemyForts)
            {
                if (fort.DefendingGuys.Count < weakestEnemy.DefendingGuys.Count)
                {
                    weakestEnemy = fort;
                }
            }

            foreach (var fort in friendlyForts)
            {
                if (FilterRunner(fort.DefendingGuys).Count != 0)
                {
                    runnersFort = fort;
                }
                if (fort.DefendingGuys.Sum(x => x.Strength) > weakestEnemy.DefendingGuys.Sum(x => x.Health))
                {
                    moves.AddRange(MoveAll(fort, weakestEnemy));
                }
            }

            // find closest neutral fort and send the runners
            if (runnersFort != null)
            {
                if (runnersFort.DefendingGuys.Count != 0)
                {
                    var closestNeutral = GetClosestFort(neutralForts, runnersFort);
                    if (closestNeutral != null)
                    {
                        moves.Add(Move(runnersFort, closestNeutral, FilterRunner(runnersFort.DefendingGuys).Count, GuyType.RUNNER));
                    }
                }
            }

            return(moves);
        }
Ejemplo n.º 20
0
        public Client(ISettings settings)
        {
            Settings          = settings;
            Proxy             = InitProxy();
            PokemonHttpClient = new PokemonHttpClient();
            Login             = new Rpc.Login(this);
            Player            = new Player(this);
            Download          = new Download(this);
            Inventory         = new Inventory(this);
            Map            = new Map(this);
            Fort           = new Fort(this);
            Encounter      = new Encounter(this);
            Misc           = new Misc(this);
            KillswitchTask = new KillSwitchTask(this);

            Player.SetCoordinates(Settings.DefaultLatitude, Settings.DefaultLongitude, Settings.DefaultAltitude);

            InventoryLastUpdateTimestamp = 0;

            Platform = settings.DevicePlatform.Equals("ios", StringComparison.Ordinal) ? Platform.Ios : Platform.Android;

            // We can no longer emulate Android so for now just overwrite settings with randomly generated iOS device info.
            if (Platform == Platform.Android)
            {
                DeviceInfo iosInfo = DeviceInfoHelper.GetRandomIosDevice();
                settings.DeviceId             = iosInfo.DeviceId;
                settings.DeviceBrand          = iosInfo.DeviceBrand;
                settings.DeviceModel          = iosInfo.DeviceModel;
                settings.DeviceModelBoot      = iosInfo.DeviceModelBoot;
                settings.HardwareManufacturer = iosInfo.HardwareManufacturer;
                settings.HardwareModel        = iosInfo.HardwareModel;
                settings.FirmwareBrand        = iosInfo.FirmwareBrand;
                settings.FirmwareType         = iosInfo.FirmwareType;

                // Clear out the android fields.
                settings.AndroidBoardName      = "";
                settings.AndroidBootloader     = "";
                settings.DeviceModelIdentifier = "";
                settings.FirmwareTags          = "";
                settings.FirmwareFingerprint   = "";

                // Now set the client platform to ios
                Platform = Platform.Ios;
            }

            AppVersion   = 4500;
            SettingsHash = "";

            CurrentApiEmulationVersion = new Version("0.45.0");
        }
Ejemplo n.º 21
0
    public void InitializeFort(Country country, Side side, int id)
    {
        fort             = MapController.fortTypes[(int)country.type];
        hexes            = new Hex[country.hexes.Count];
        revenueTurnsLeft = fort.revenueTurns;
        capacity         = fort.capacity;
        planes           = new UnitObject[capacity];
        initialSide      = side;
        this.side        = Side.None;

        fortModel = Instantiate(fort.model, transform);
        fortModel.transform.localPosition = Vector3.zero;
        canGetMoney = true;
        this.id     = id;
    }
Ejemplo n.º 22
0
    BulletBasic createBullet(Collider LockCollider, Fort fort)
    {
        var Bullet = BulletPool.Obtain(BulletType);

        Bullet.SetPosition(ShotSpwan);
        Bullet.SetRotation(transform.rotation);
        Bullet.SetEnable();

        Vector3 direction = (LockCollider.gameObject.transform.position - fort.transform.position).normalized;

        Bullet.SetVelocity(direction, fort.Speed);
        Bullet.damage = fort.Damage;

        return(Bullet);
    }
Ejemplo n.º 23
0
        public Fort GetClosestFort(List <Fort> forts, Fort srcFort)
        {
            Fort   closestFort      = null;
            double shortestDistance = double.MaxValue;

            foreach (var fort in forts)
            {
                var distance = GetDistanceBetween(srcFort.Location, fort.Location);
                if (distance < shortestDistance)
                {
                    shortestDistance = distance;
                    closestFort      = fort;
                }
            }
            return(closestFort);
        }
Ejemplo n.º 24
0
 public void CollideWithFort(Fort f)
 {
     foreach (Unit u in units)
     {
         if (u.box == null)
         {
             continue;
         }
         Mob m = (Mob)u;
         if (m.box.overlap(f.box))
         {
             f.hitpoints -= m.fortDamage;
             m.hitPoints  = 0;
         }
     }
 }
Ejemplo n.º 25
0
    // Use this for initialization
    void Start()
    {
        if (fort1 == null || fort2 == null)
        {
            fort1 = GetComponentsInChildren <Fort>()[0];
            fort2 = GetComponentsInChildren <Fort>()[1];
        }
        _cardControllerInstance = FindObjectOfType <CardController>();

        _player1 = new Player(fort1);
        _player2 = new Player(fort2);

        _activePlayer = _player1;

        _player1.Fort.myWinLose += OnWinLoseCondition;
        _player2.Fort.myWinLose += OnWinLoseCondition;
    }
Ejemplo n.º 26
0
        public Client(ISettings settings, IApiFailureStrategy apiFailureStrategy)
        {
            Settings          = settings;
            ApiFailure        = apiFailureStrategy;
            Proxy             = InitProxy();
            PokemonHttpClient = new PokemonHttpClient();
            Login             = new Rpc.Login(this);
            Player            = new Player(this);
            Download          = new Download(this);
            Inventory         = new Inventory(this);
            Map       = new Map(this);
            Fort      = new Fort(this);
            Encounter = new Encounter(this);
            Misc      = new Misc(this);

            Player.SetCoordinates(Settings.DefaultLatitude, Settings.DefaultLongitude, Settings.DefaultAltitude);
        }
Ejemplo n.º 27
0
    // Use this for initialization
    void Start()
    {
        if (fort1 == null || fort2 == null)
        {
            fort1 = GetComponentsInChildren<Fort>()[0];
            fort2 = GetComponentsInChildren<Fort>()[1];
        }
        _cardControllerInstance = FindObjectOfType<CardController>();

        _player1 = new Player(fort1);
        _player2 = new Player(fort2);

        _activePlayer = _player1;

        _player1.Fort.myWinLose += OnWinLoseCondition;
        _player2.Fort.myWinLose += OnWinLoseCondition;
    }
Ejemplo n.º 28
0
        public Client(ISettings settings, IApiFailureStrategy apiFailureStrategy, IDeviceInfo deviceInfo)
        {
            Settings   = settings;
            ApiFailure = apiFailureStrategy;

            Login      = new Rpc.Login(this);
            Player     = new Player(this);
            Download   = new Download(this);
            Inventory  = new Inventory(this);
            Map        = new Map(this);
            Fort       = new Fort(this);
            Encounter  = new Encounter(this);
            Misc       = new Misc(this);
            DeviceInfo = deviceInfo;

            Player.SetCoordinates(Settings.DefaultLatitude, Settings.DefaultLongitude, Settings.DefaultAltitude);
        }
Ejemplo n.º 29
0
 void set_fort_enable()
 {
     for (int i = 0; i < fort_list.Length; i++)
     {
         Fort fort = fort_list[i];
         if (fort)
         {
             if (i == level)
             {
                 fort.gameObject.SetActive(true);
             }
             else
             {
                 fort.gameObject.SetActive(false);
             }
         }
     }
 }
Ejemplo n.º 30
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (WildPokemon != 0)
            {
                hash ^= WildPokemon.GetHashCode();
            }
            if (Fort != 0)
            {
                hash ^= Fort.GetHashCode();
            }
            if (FortsNearby != 0)
            {
                hash ^= FortsNearby.GetHashCode();
            }
            return(hash);
        }
Ejemplo n.º 31
0
        public async Task <ResponseMessage> CreateUser(string Name, string EmailId, string Password)
        {
            if ((Name != null || Name != "") && (EmailId != null || EmailId != "") && (Password != null || Password != ""))
            {
                var existUser = await _fortRepository.ValidateUser(EmailId, Password);

                if (existUser != null)
                {
                    return(new ResponseMessage {
                        Status = "Ok", Message = "Duplicate user"
                    });
                }
                else
                {
                    Fort fort = new Fort();
                    fort.Name     = Name;
                    fort.Email    = EmailId;
                    fort.Password = Password;


                    var UserResponse = await _fortRepository.UpdateOneAsync(fort, true);

                    if (UserResponse != null)
                    {
                        return new ResponseMessage {
                                   Status = "Ok", Message = "User Created SuccessFully"
                        }
                    }
                    ;
                    else
                    {
                        return new ResponseMessage {
                                   Status = "Error", Message = "Error in UserCreation"
                        }
                    };
                }
            }
            else
            {
                return(new ResponseMessage {
                    Status = "Error", Message = "Please Fill Email,Name And Password."
                });
            }
        }
Ejemplo n.º 32
0
        public void DrawFort(Fort fort)
        {
            int size = 25;

            var circle = new Ellipse();

            circle.SetValue(Canvas.TopProperty, (double)fort.Location.Y);
            circle.SetValue(Canvas.LeftProperty, (double)fort.Location.X);
            circle.Height          = size;
            circle.Width           = circle.Height;
            circle.StrokeThickness = 2;
            circle.Stroke          = Brushes.Black;
            //circle.Stroke = m_playerColorMapping[fort.FortOwner.Name];
            Canvas.Children.Add(circle);

            DrawText(fort.Location.X + size / 4 - 4, fort.Location.Y + size / 4 - 1, fort.BirthSpeed.ToString(), Colors.Black);
            DrawText(fort.Location.X - 3, fort.Location.Y - size / 2 - 2, fort.ID + ":" + fort.GetOwnerName(), Colors.Black);
            DrawText(fort.Location.X + size / 4 - 4, fort.Location.Y + size, fort.NumDefendingGuys.ToString(), Colors.Black);
        }
Ejemplo n.º 33
0
    // Use this for initialization
    void Start()
    {
        fort      = GameObject.FindObjectOfType <Fort>().GetComponent <Fort>();
        spawner   = GameObject.FindObjectOfType <Spawner>().GetComponent <Spawner>();
        animator  = GetComponent <Animator>();
        layerMask = LayerMask.GetMask("Building");

        List <Transform> targets_ = GameObject.FindGameObjectWithTag("Wall").GetComponentsInChildren <Transform>().ToList();

        targets_.RemoveAt(0);
        foreach (Transform target in targets_)
        {
            if (target.tag == "Target")
            {
                targets.Add(target.GetComponentInChildren <Transform>());
            }
        }

        aicc = GetComponent <AICharacterControl>();
        aicc.SetTarget(targets[Random.Range(0, targets.Count - 1)]);
    }
Ejemplo n.º 34
0
 public Player(Fort fort)
 {
     _fort = fort;
     _cardControllerInstance = GameObject.FindObjectOfType<CardController>();
     _playControllerInstance = GameObject.FindObjectOfType<PlayController>();
 }
Ejemplo n.º 35
0
 public bool CompareFort(Fort fort)
 {
     return Fort == fort;
 }
Ejemplo n.º 36
0
 public void CollideWithFort (Fort f) {
     foreach (Unit u in units)
     {
         if (u.box == null) {
             continue;
         }
         Mob m = (Mob) u;
         if (m.box.overlap(f.box))
         {
             f.hitpoints -= m.fortDamage;
             m.hitPoints = 0;
         }
     }
 }