Exemple #1
0
 public override void SetActiveInteractive(PlotObject plot, bool isActive, string id)
 {
     uiPanel.SetActive(true);
     Game.isPause   = true;
     this.plot      = plot;
     Time.timeScale = 0;
     idName         = id;
 }
Exemple #2
0
 public override void SetActiveInteractive(PlotObject plot, bool isActive, string id)
 {
     isInteractiveEnable = isActive;
     this.plot           = plot;
     canvasPressIcon.SetActive(false);
     canvasPointer.SetActive(true);
     isPossibleInteractivePanel = false;
     idName = id;
 }
Exemple #3
0
    // initialize plot grid
    private void Initialize()
    {
        plotDict = new Dictionary <int, PlotObject>();

        foreach (Transform childTransform in transform)
        {
            int xVal = (int)childTransform.position.x;
            int zVal = (int)childTransform.position.z;

            PlotObject po = childTransform.GetComponent <PlotObject>();
            Debug.Assert(po != null);
            plotDict.Add(xVal * XVALUEMULTIPLIER + zVal, po);
            plotDict[xVal * XVALUEMULTIPLIER + zVal].Initialize(this, xVal, zVal);
        }
    }
Exemple #4
0
    // get nearest enemy plot
    public PlotObject GetNearestEnemy(PlotObject plot)
    {
        if (plot.PlotTemplate.aiPlot == null)
        {
            return(null);
        }

        PlotObject returnPlot;

        // upper row
        if (plotDict.TryGetValue((plot.XValue + 1) * XVALUEMULTIPLIER + plot.ZValue, out returnPlot))
        {
            if (returnPlot.PlotTemplate == aiPlotTemplate)
            {
                return(returnPlot);
            }
        }

        // lower row
        if (plotDict.TryGetValue((plot.XValue - 1) * XVALUEMULTIPLIER + plot.ZValue, out returnPlot))
        {
            if (returnPlot.PlotTemplate == aiPlotTemplate)
            {
                return(returnPlot);
            }
        }

        // left column
        if (plotDict.TryGetValue(plot.XValue * XVALUEMULTIPLIER + (plot.ZValue - 1), out returnPlot))
        {
            if (returnPlot.PlotTemplate == aiPlotTemplate)
            {
                return(returnPlot);
            }
        }

        // right column
        if (plotDict.TryGetValue(plot.XValue * XVALUEMULTIPLIER + (plot.ZValue + 1), out returnPlot))
        {
            if (returnPlot.PlotTemplate == aiPlotTemplate)
            {
                return(returnPlot);
            }
        }

        return(returnPlot = null);
    }
Exemple #5
0
    private void Update()
    {
        // check if there is at least an attackable plot
        if (grid.AttackablePlots.Count <= 0)
        {
            return;
        }

        // check cooldown and start enemy spawn timer
        if (cooldownCurrent > 0)
        {
            cooldownCurrent -= Time.deltaTime;
        }
        else
        {
            timeAverage = (attackableCurve.Evaluate(grid.AttackablePlotPercentage) + timeProbabilityCurve.Evaluate(timer.CurrentTimePercentage) + treeCurve.Evaluate(grid.treePlotPercentage)) / 3;

            if ((Time.deltaTime / timeAverage) >= Random.value)
            {
                List <PlotObject> plotList = new List <PlotObject>();

                grid.GetAttackablePlotsByTemplate(ref plotList, buildableTemplate);

                if (plotList.Count > 0)
                {
                    plotToAttack = plotList[Random.Range(0, plotList.Count - 1)];
                }
                else
                {
                    grid.GetAttackablePlotsByDifferences(ref plotList, buildableTemplate);

                    plotToAttack = plotList[Random.Range(0, plotList.Count - 1)];
                }

                // start plot attack
                if (plotToAttack != null)
                {
                    plotToAttack.StartCoroutine(plotToAttack.AttackPlot(spawnTime));
                    plotToAttack = null;
                    InitializeTimer();
                }
            }
        }
    }
        private void cmbDataSource_SelectedIndexChanged(object sender, EventArgs e)
        {
            PlotObject p = cmbDataSource.SelectedItem as PlotObject;

            if (p == null)
            {
                return;
            }

            manualUpdate = true;

            plotView.Model = p.PlotModel;
            currentPlot    = p;
            tbTitle.Text   = plotView.Model.Title;
            tbXAxis.Text   = plotView.Model.Axes[0].Title;
            tbYAxis.Text   = plotView.Model.Axes[1].Title;

            manualUpdate = false;
        }
Exemple #7
0
    // destroy a tile and replace it
    public void ChangeTile(PlotObject tileToReplace, GameObject tileToInstantiate, int score)
    {
        int poIndex = tileToReplace.XValue * XVALUEMULTIPLIER + tileToReplace.ZValue;

        plotDict[poIndex] = Instantiate(tileToInstantiate, transform).GetComponent <PlotObject>();
        plotDict[poIndex].transform.position = new Vector3(tileToReplace.XValue, 0, tileToReplace.ZValue);

        plotDict[poIndex].Initialize(this, tileToReplace.XValue, tileToReplace.ZValue, tileToReplace.SkinIndex);

        // get nearest enemy plot for the new plot and the four adjacent plots (recursive my wildest dream!!!)
        plotDict[poIndex].EnemyPlot = GetNearestEnemy(plotDict[tileToReplace.XValue * XVALUEMULTIPLIER + tileToReplace.ZValue]);

        plotDict[(tileToReplace.XValue - 1) * XVALUEMULTIPLIER + tileToReplace.ZValue].EnemyPlot = GetNearestEnemy(plotDict[(tileToReplace.XValue - 1) * XVALUEMULTIPLIER + tileToReplace.ZValue]);
        plotDict[(tileToReplace.XValue + 1) * XVALUEMULTIPLIER + tileToReplace.ZValue].EnemyPlot = GetNearestEnemy(plotDict[(tileToReplace.XValue + 1) * XVALUEMULTIPLIER + tileToReplace.ZValue]);
        plotDict[tileToReplace.XValue * XVALUEMULTIPLIER + tileToReplace.ZValue - 1].EnemyPlot   = GetNearestEnemy(plotDict[tileToReplace.XValue * XVALUEMULTIPLIER + tileToReplace.ZValue - 1]);
        plotDict[tileToReplace.XValue * XVALUEMULTIPLIER + tileToReplace.ZValue + 1].EnemyPlot   = GetNearestEnemy(plotDict[tileToReplace.XValue * XVALUEMULTIPLIER + tileToReplace.ZValue + 1]);

        // destroy the old plot
        Destroy(tileToReplace.gameObject);

        if (score != 0)
        {
            Bounds bounds = plotDict[poIndex].gameObject.GetComponentInChildren <Renderer>().bounds;

            PopupPoint popup = Instantiate(popupPointsPrefab, new Vector3(plotDict[poIndex].transform.position.x, plotDict[poIndex].transform.position.y + popupOffsetY, plotDict[poIndex].transform.position.z), Quaternion.identity).GetComponent <PopupPoint>();

            if (score > 0)
            {
                popup.SetText("+" + score.ToString());
            }
            else
            {
                popup.SetText(score.ToString());
            }
        }

        GameManager.Instance.ChangeScore(score);
    }
Exemple #8
0
 public override void SetActiveInteractive(PlotObject plot, bool isActive, string id)
 {
     this.isActive = isActive;
     this.plot     = plot;
     idName        = id;
 }
Exemple #9
0
 public virtual void SetActiveInteractive(PlotObject plot, bool isActive, string id)
 {
 }
Exemple #10
0
 protected override void Awake()
 {
     base.Awake();
     plotObject = GetComponent <PlotObject>();
 }