Ejemplo n.º 1
0
 public void OnClick()
 {
     if (BuildingManager.ActiveBuilding.State == BuildingState.MOVING)
     {
         // Moving
         if (BuildingModeGrid.GetInstance().CanObjectBePlacedAtPosition(BuildingManager.ActiveBuilding, BuildingManager.ActiveBuilding.MovePosition))
         {
             if (BuildingManager.GetInstance().MoveBuilding())
             {
                 UIGamePanel.ShowPanel(PanelType.DEFAULT);
             }
         }
     }
     else
     {
         // Placing
         if (BuildingModeGrid.GetInstance().CanObjectBePlacedAtPosition(BuildingManager.ActiveBuilding, BuildingManager.ActiveBuilding.Position))
         {
             if (BuildingManager.GetInstance().PlaceBuilding())
             {
                 UIGamePanel.ShowPanel(PanelType.DEFAULT);
             }
         }
     }
 }
 public void OnClick()
 {
     if (BuildingManager.ActiveBuilding != null && canDismiss)
     {
         BuildingManager.ActiveBuilding.DismissOccupant(occupant);
         UIGamePanel.ShowPanel(PanelType.VIEW_OCCUPANTS);
     }
 }
 /**
  * Button clicked, start activity.
  */
 override public void OnClick()
 {
     if (ResourceManager.Instance.Resources > myBuilding.Type.cost)
     {
         myBuilding.StartActivity(ActivityType.CLEAR, System.DateTime.Now, "");
         UIGamePanel.ShowPanel(PanelType.DEFAULT);
     }
 }
    public void OnCardClick(int cardSlot)
    {
        UIBuyCardPanel panel = UIGamePanel.GetPanel <UIBuyCardPanel>(PanelType.BUY_CARD_PANEL);

        panel.Card = Cyclades.Game.Constants.cardChimera;
        panel.SetPrice(5 - cardSlot);

        UIGamePanel.ShowPanel(PanelType.BUY_CARD_PANEL);
    }
 /**
  * Start the generic activity function.
  */
 public void DoActivity(string type, string supportingId)
 {
     if (BuildingManager.ActiveBuilding.StartActivity(type, System.DateTime.Now, supportingId))
     {
         UIGamePanel.ShowPanel(PanelType.DEFAULT);
     }
     else
     {
         Debug.LogWarning("This is where you pop up your IAP screen");
     }
 }
Ejemplo n.º 6
0
    public void OnConreteAuctionGodClick(int number)
    {
        UIAuctionPanel panel = UIGamePanel.GetPanel <UIAuctionPanel>(PanelType.AUCTION_PANEL);

        panel.MinBet     = 0;
        panel.MaxBet     = 10;
        panel.GodName    = Cyclades.Game.Constants.godMars;
        panel.CurrentBet = number;

        UIGamePanel.ShowPanel(PanelType.AUCTION_PANEL, this);
    }
 public void OnClick()
 {
     if (ResourceManager.Instance.CanBuild(BuildingManager.GetInstance().GetBuildingTypeData(buildingTypeId)))
     {
         BuildingManager.GetInstance().CreateBuilding(buildingTypeId);
         UIGamePanel.ShowPanel(PanelType.PLACE_BUILDING);
     }
     else
     {
         Debug.LogWarning("This is where you bring up your in app purchase screen");
     }
 }
 public void OnClick()
 {
     if (isGold)
     {
         BuildingManager.GetInstance().SellBuildingForGold(BuildingManager.ActiveBuilding);
     }
     else
     {
         BuildingManager.GetInstance().SellBuilding(BuildingManager.ActiveBuilding, false);
     }
     UIGamePanel.ShowPanel(PanelType.DEFAULT);
     BuildingManager.ActiveBuilding = null;
 }
Ejemplo n.º 9
0
 /**
  * Update the labels as time passes.
  */
 protected IEnumerator UpdateLabels()
 {
     while (BuildingManager.ActiveBuilding != null && BuildingManager.ActiveBuilding.CurrentActivity != null && BuildingManager.ActiveBuilding.CurrentActivity.RemainingTime.TotalSeconds > 0)
     {
         timeLabel.text = string.Format("Time Remaining: {0} minutes {1} second{2}", (int)BuildingManager.ActiveBuilding.CurrentActivity.RemainingTime.TotalMinutes, BuildingManager.ActiveBuilding.CurrentActivity.RemainingTime.Seconds, (BuildingManager.ActiveBuilding.CurrentActivity.RemainingTime.Seconds != 1 ? "s" : ""));
         goldLabel.text = ((int)Mathf.Max(1, (float)(BuildingManager.ActiveBuilding.CurrentActivity.RemainingTime.TotalSeconds + 1) / (float)BuildingManager.GOLD_TO_SECONDS_RATIO)).ToString();
         yield return(true);
     }
     // If we get to here we finished... hide this panel.
     if (BuildingManager.ActiveBuilding != null && BuildingManager.ActiveBuilding.CurrentActivity != null)
     {
         UIGamePanel.ShowPanel(PanelType.DEFAULT);
     }
 }
    public void OnClick()
    {
        List <Activity> activities = ActivityManager.GetInstance().GetActivitiesOfDataClassType(typeof(AttackActivityData));

        if (activities == null || activities.Count == 0)
        {
            UIGamePanel.ShowPanel(PanelType.TARGET_SELECT);
        }
        else
        {
            // This button only handles one activity
            if (activities[0].PercentageComplete >= 1)
            {
                ActivityManager.GetInstance().AcknowledgeActivity(activities[0]);
            }
        }
    }
Ejemplo n.º 11
0
 public void OnClick()
 {
     if (building.State == BuildingState.READY)
     {
         BuildingManager.GetInstance().AcknowledgeBuilding(building);
     }
     else if (building.State == BuildingState.IN_PROGRESS || building.CurrentActivity != null)
     {
         UIGamePanel.ShowPanel(PanelType.SPEED_UP);
         if (UIGamePanel.activePanel is UISpeedUpPanel)
         {
             ((UISpeedUpPanel)UIGamePanel.activePanel).InitialiseWithBuilding(building);
         }
     }
     else
     {
         building.AcknowledgeActivity();
     }
 }
Ejemplo n.º 12
0
 public void OnClick()
 {
     if (BuildingManager.ActiveBuilding != null)
     {
         // Moving
         if (BuildingManager.ActiveBuilding.State == BuildingState.MOVING)
         {
             BuildingManager.ActiveBuilding.ResetPosition();
             BuildingManager.ActiveBuilding.FinishMoving();
             UIGamePanel.ShowPanel(PanelType.DEFAULT);
         }
         else
         {
             // Placing
             if (BuildingManager.GetInstance().SellBuilding(BuildingManager.ActiveBuilding, true))
             {
                 UIGamePanel.ShowPanel(PanelType.DEFAULT);
             }
         }
     }
 }
 public void OnClick()
 {
     if (building.Type.isObstacle)
     {
         if (building.CurrentActivity == null && building.CompletedActivity == null)
         {
             UIGamePanel.ShowPanel(PanelType.OBSTACLE_INFO);
             if (UIGamePanel.activePanel is UIBuildingInfoPanel)
             {
                 ((UIBuildingInfoPanel)UIGamePanel.activePanel).InitialiseWithBuilding(building);
             }
         }
     }
     else if (building.State == BuildingState.BUILT)
     {
         UIGamePanel.ShowPanel(PanelType.BUILDING_INFO);
         if (UIGamePanel.activePanel is UIBuildingInfoPanel)
         {
             ((UIBuildingInfoPanel)UIGamePanel.activePanel).InitialiseWithBuilding(building);
         }
     }
 }
Ejemplo n.º 14
0
 public void OnClick()
 {
     UIGamePanel.ShowPanel(PanelType.RECRUIT_OCCUPANTS);
     // if (UIGamePanel.activePanel is UIOccupantSelect) ((UIOccupantSelect)UIGamePanel.activePanel).InitialiseWithBuilding(BuildingManager.ActiveBuilding);
 }
    /**
     * Handle the battle results calculations
     */
    public void CustomReward(Activity activity)
    {
        List <string> losses            = new List <string>();
        int           goldRewarded      = 0;
        int           resourcesRewarded = 0;
        ActivityData  type = ActivityManager.GetInstance().GetActivityData(activity.Type);

        if (type is AttackActivityData)
        {
            int troopStrength = 0;
            foreach (string s in activity.SupportingIds)
            {
                OccupantData o = OccupantManager.GetInstance().GetOccupant(s);
                if (o != null && o.Type is AttackerOccupantTypeData)
                {
                    troopStrength += ((AttackerOccupantTypeData)o.Type).attack;
                }
            }
            // Calculate result
            bool winner = false;
            if (troopStrength >= ((AttackActivityData)type).strength * 2)
            {
                winner = true;
                // No losses
            }
            else if (troopStrength >= ((AttackActivityData)type).strength)
            {
                if (Random.Range(0, 3) != 0)
                {
                    winner = true;
                }
                // 25% chance of losing each unit
                losses.AddRange(activity.SupportingIds.Where(o => Random.Range(0, 4) == 0).ToList());
                // Ensure at least one troop member survives
                if (losses.Count == activity.SupportingIds.Count)
                {
                    losses.RemoveAt(0);
                }
            }
            else if (troopStrength >= (int)(((AttackActivityData)type).strength * 0.5f))
            {
                // Calculate losses
                if (Random.Range(0, 3) == 0)
                {
                    winner = true;
                }
                // 50% chance of losing each unit
                losses.AddRange(activity.SupportingIds.Where(o => Random.Range(0, 2) == 0).ToList());
                // Ensure at least one troop member survives
                if (losses.Count == activity.SupportingIds.Count)
                {
                    losses.RemoveAt(0);
                }
            }
            else
            {
                // Lose everyone
                losses.AddRange(activity.SupportingIds);
            }

            // Calculate reward
            if (winner)
            {
                goldRewarded      = Random.Range(0, type.rewardAmount + 1);
                resourcesRewarded = Random.Range(1, type.rewardAmount + 1) * 100;
            }

            // Remove occupants
            string lossesString = "";
            foreach (string o in losses)
            {
                lossesString += OccupantManager.GetInstance().GetOccupant(o).Type.name + ", ";
            }
            foreach (string o in losses)
            {
                OccupantManager.GetInstance().DismissOccupant(o);
            }
            if (lossesString.Length > 0)
            {
                lossesString.Substring(0, lossesString.Length - 2);
            }

            // Add rewards
            ResourceManager.Instance.AddResources(resourcesRewarded);
            ResourceManager.Instance.AddGold(goldRewarded);

            // Show panel -
            UIBattleResultsPanel panel = (UIBattleResultsPanel)FindObjectOfType(typeof(UIBattleResultsPanel));
            if (panel != null)
            {
                panel.InitialiseWithResults(winner, lossesString, goldRewarded, resourcesRewarded);
                UIGamePanel.ShowPanel(PanelType.BATTLE_RESULTS);
            }
        }
    }
Ejemplo n.º 16
0
 public void OnClick()
 {
     BuildingManager.ActiveBuilding.StartMoving();
     UIGamePanel.ShowPanel(PanelType.PLACE_BUILDING);
 }
Ejemplo n.º 17
0
 public void OnClick()
 {
     UIGamePanel.ShowPanel(PanelType.SELL_BUILDING);
     ((UISellBuildingPanel)UIGamePanel.activePanel).InitialiseWithBuilding(BuildingManager.ActiveBuilding);
 }
Ejemplo n.º 18
0
 public void OnClick()
 {
     ActivityManager.GetInstance().StartActivity(activity, System.DateTime.Now, OccupantManager.GetInstance().GetAllOccupants().Select(o => o.uid).ToList());
     UIGamePanel.ShowPanel(PanelType.DEFAULT);
 }
Ejemplo n.º 19
0
 public void OnClick()
 {
     UIGamePanel.ShowPanel(type);
 }
 /**
  * Start the generic activty function.
  */
 public void DoActivity(string type, string supportingId)
 {
     building.StartActivity(type, System.DateTime.Now, supportingId);
     UIGamePanel.ShowPanel(PanelType.DEFAULT);
 }
Ejemplo n.º 21
0
 public void OnClick()
 {
     BuildingManager.GetInstance().SpeedUp();
     UIGamePanel.ShowPanel(PanelType.DEFAULT);
 }