Example #1
0
    private void GetBestDraughtOptions(GameObject draught)
    {
        bestDraughtOptions.Clear();
        bestDraughtOptions.Add(FireOption.BadOption);
        foreach (Transform draughtT in playerDraughtsParent.transform)
        {
            Vector3 currVec    = draughtT.position - draught.transform.position;
            var     currOption = new FireOption(draught, currVec, draughtMaxForce);

            if (!draughtT.GetComponent <DraughtController>().isActive)
            {
                currOption.Rating -= deactivatedTargetPenalty;
            }

            if (currOption.Rating == bestDraughtOptions[0].Rating)
            {
                bestDraughtOptions.Add(currOption);
            }
            else if (currOption.Rating > bestDraughtOptions[0].Rating)
            {
                bestDraughtOptions.Clear();
                bestDraughtOptions.Add(currOption);
            }
        }
    }
Example #2
0
    private void SetBestAliveOption(List <GameObject> aliveDraughts)
    {
        var bestOptions = new List <FireOption>();

        for (int i = 0; i < Mathf.Min(draughtsPerRaw, aliveDraughts.Count); ++i)
        {
            GameObject currDraught = aliveDraughts[i];
            GetBestDraughtOptions(currDraught);

            if (bestOptions.Count == 0)
            {
                bestOptions.AddRange(bestDraughtOptions);
            }
            else if (bestDraughtOptions[0].Rating == bestOptions[0].Rating)
            {
                bestOptions.AddRange(bestDraughtOptions);
            }
            else if (bestDraughtOptions[0].Rating > bestOptions[0].Rating)
            {
                bestOptions.Clear();
                bestOptions.AddRange(bestDraughtOptions);
            }
        }

        bestOption            = bestOptions[UnityEngine.Random.Range(0, bestOptions.Count - 1)];
        activeDraughtID.Value = bestOption.Draught.GetInstanceID();
    }
Example #3
0
 private void SetRandomOption(List <GameObject> aliveDraughts)
 {
     bestOption = new FireOption(
         aliveDraughts[UnityEngine.Random.Range(0, aliveDraughts.Count - 1)],
         Vector3.zero,
         0
         );
     activeDraughtID.Value = bestOption.Draught.GetInstanceID();
 }