Example #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");
        }
Example #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");
         }
     }
 }
Example #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");
         }
     }
 }
Example #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();
    }
Example #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);
        }
Example #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));
            }
        }
    }
Example #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);
        }
Example #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++;
 }
Example #10
0
 public static Fort GetInstance()
 {
     if (instance == null)
     {
         instance = GameObject.Find("Fort").GetComponent <Fort>();
     }
     return(instance);
 }
Example #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>();
 }
Example #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>();
 }
Example #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);
        }
    }
    // 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);
    }
Example #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)
     });
 }
Example #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));
        }
Example #17
0
 void Awake()
 {
     killedOrks = new HashSet <Ork>();
     Hut.ResetAll();
     Fort.ResetAll();
     Villager.ResetAll();
     Ork.ResetAll();
     SecondsOfPlay        = 0;
     villagersHaveSpawned = false;
     FireBreathed         = 0f;
 }
Example #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 }
            });
        }
Example #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);
        }
Example #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");
        }
Example #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;
    }
Example #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);
    }
Example #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);
        }
Example #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;
         }
     }
 }
Example #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;
    }
Example #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);
        }
Example #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;
    }
Example #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);
        }
Example #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);
             }
         }
     }
 }
Example #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);
        }
        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."
                });
            }
        }
Example #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);
        }
Example #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)]);
    }
Example #34
0
 public Player(Fort fort)
 {
     _fort = fort;
     _cardControllerInstance = GameObject.FindObjectOfType<CardController>();
     _playControllerInstance = GameObject.FindObjectOfType<PlayController>();
 }
Example #35
0
 public bool CompareFort(Fort fort)
 {
     return Fort == fort;
 }
Example #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;
         }
     }
 }