Пример #1
0
    private IEnumerator coClearBases()
    {
        //WWW request = RequestService.makeRequest ("world/clear", currentBases [0].GetComponent<TouchBase>().b);
        WWW request = RequestService.makeRequest("world/clear", ObjectInstanceDictionary.getObjectInstanceById("Base", 1));

        yield return(request);

        ObjectInstanceDictionary.clearDictionary();
        UpdateGold.instance.syncGold();
        GenerateWorld.instance.resetWorldView();
    }
Пример #2
0
    private static void processAttackDefendingResults(Attack attack, AttackResultObj result)
    {
        bool isWinner = result.winnerUsername.Equals(Globals.username);

        Debug.Log("AttackID: " + attack.attackId + " Won? " + isWinner + " result: " + result);

        if (isWinner)
        {
            Debug.Log("Survived attack! Surviving units - New num units: " + result.numUnitsLeft);
            // Update num units
            Base b = (Base)ObjectInstanceDictionary.getObjectInstanceById("Base", attack.defenderBaseId);
            GenerateWorld.instance.message.text = "Survived getting attacked! Lost " + (b.units - result.numUnitsLeft) + " units";
            b.units = result.numUnitsLeft;
            EventManager.positionText();

            WormHole w = attack.defenderWormHole;
            w.attackState = AttackState.NoAttack;
            // Remove progress bar
        }
        else
        {
            GenerateWorld.instance.message.text = "Defeated in attack. Base lost.";
            Debug.Log("Didn't survive attack - lost base BaseId: " + attack.defenderBaseId);
            // Delete base and connecting portals
            // Get all connecting portals
            foreach (int pId in result.lostPortalIds)
            {
                GameObject p = ObjectInstanceDictionary.getObjectInstanceById("Portal", pId).gameObject;
                Destroy(p);
            }
            // TODO: Delete all of the base's wormholes, not just the one that the attack came through
            Destroy(attack.defenderWormHole.gameObject);
            GameObject b = ObjectInstanceDictionary.getObjectInstanceById("Base", attack.defenderBaseId).gameObject;
            Destroy(b.GetComponent <BaseScript>().objectInfoPanel);
            Destroy(b);
            EventManager.positionText();
        }
    }
Пример #3
0
    public IEnumerator coOnAttackConfirmed(int numUnits)
    {
        WormHole w       = (WormHole)gameObject.GetComponent <InstanceObjectScript> ().instanceObject;
        Base     b       = w.b;
        WWWForm  wwwform = new WWWForm();

        wwwform.AddField("username", "kmw8sf");
        wwwform.AddField("baseId", b.baseId);
        wwwform.AddField("wormholeId", w.wormholeId);
        wwwform.AddField("numUnits", numUnits);
        WWW request = new WWW("localhost:8080/myapp/world/attack", wwwform);

        yield return(request);

        Attack attack = LitJson.JsonMapper.ToObject <Attack> (request.text);

        if (attack.attackerBaseId != null)
        {
            AttackHandler.instance.addAttack(attack);
            Base attackBase = (Base)ObjectInstanceDictionary.getObjectInstanceById("Base", attack.attackerBaseId);
            attackBase.units -= numUnits;
            EventManager.positionText();
        }
    }