Пример #1
0
    /// <summary>
    /// Initializes the combat system.
    /// </summary>
    /// <param name="offensiveSquad">GameObject for the squad performing the attack.</param>
    /// <param name="defensiveSquad">GameObject for the squad on defense.</param>
    public void BeginCombat(CombatSquadBehavior offensiveSquad, CombatSquadBehavior defensiveSquad)
    {
        if (offensiveSquad.Squad == null || defensiveSquad.Squad == null)
        {
            Debug.LogError("Combat was started with either the offensive or defense squad being null!");
            return;
        }

        GridBehavior.inCombat = true;
        InCombat = true;

        this.offensiveSquad = offensiveSquad;
        this.defensiveSquad = defensiveSquad;

        Debug.Log("Combat between " + offensiveSquad.ToString() + " and " + defensiveSquad.ToString() + " begin.");

        Debug.Log("Offensive size: " + offensiveSquad.Squad.Units.Count);
        Debug.Log("Defensive size: " + defensiveSquad.Squad.Units.Count);

        int unitCount = offensiveSquad.Squad.Units.Count + defensiveSquad.Squad.Units.Count;
        unitPrefabs = new List<NodeSkeletonBehavior>(unitCount);

        foreach(UnitData data in offensiveSquad.Squad.Units)
        {
            float x = -1.0f + (0.33f * data.Position.Row);
            float y = 0.7f - (0.33f * data.Position.Column);
            float z = 0.9f - (0.05f * data.Position.Column);

            NodeSkeletonBehavior skele = (NodeSkeletonBehavior)Instantiate(unitSkeleton);

            skele.transform.parent = transform;
            skele.transform.localScale = (Vector3.one / 2.0f);
            skele.transform.localPosition = Vector3.zero;

            skele.transform.Translate(x, y, z);
        }

        foreach (UnitData data in defensiveSquad.Squad.Units)
        {
            float x = 1.0f - (0.33f * data.Position.Row);
            float y = 0.7f - (0.33f * data.Position.Column);
            float z = 0.9f - (0.05f * data.Position.Column);

            NodeSkeletonBehavior skele = (NodeSkeletonBehavior)Instantiate(unitSkeleton);

            skele.transform.parent = transform;
            skele.transform.localScale = new Vector3(-0.5f, 0.5f, 0.5f);
            skele.transform.localPosition = Vector3.zero;

            skele.transform.Translate(x, y, z);
        }

        currentAttacker = CurrentAttacker.OffensiveFront;
    }
Пример #2
0
    /// <summary>
    /// Initializes the combat system.
    /// </summary>
    /// <param name="offensiveSquad">GameObject for the squad performing the attack.</param>
    /// <param name="defensiveSquad">GameObject for the squad on defense.</param>
    public void BeginCombat(CombatSquadBehavior offensiveSquad, CombatSquadBehavior defensiveSquad)
    {
        if (offensiveSquad.Squad == null || defensiveSquad.Squad == null)
        {
            Debug.LogError("Combat was started with either the offensive or defense squad being null!");
            return;
        }

        GridBehavior.inCombat = true;
        InCombat = true;

        this.offensiveSquad = offensiveSquad;
        this.defensiveSquad = defensiveSquad;

        Debug.Log("Combat between " + offensiveSquad.ToString() + " and " + defensiveSquad.ToString() + " begin.");

        Debug.Log("Offensive size: " + offensiveSquad.Squad.Units.Count);
        Debug.Log("Defensive size: " + defensiveSquad.Squad.Units.Count);

        int unitCount = offensiveSquad.Squad.Units.Count + defensiveSquad.Squad.Units.Count;
        unitPrefabs = new List<NodeSkeletonBehavior>(unitCount);

        createUnits(offensiveSquad.Squad.Units, true, 0.0f);
        createUnits (defensiveSquad.Squad.Units, false, 1.0f);

        currentAttacker = CurrentAttacker.OffensiveFront;
    }