Exemplo n.º 1
0
    // Handle unit selection
    private void unitSelection()
    {
        if (SelectedUnitGroup != null)
        {
            SelectedUnitGroup.SendMessage("OnUnselected", SendMessageOptions.DontRequireReceiver);
            SelectedUnitGroup = null;
        }
        // Cast ray to see if object hit is selectable
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            if (hit.transform.gameObject.tag.Contains(vars.selectable_tag) &&
                hit.transform.gameObject.tag.Contains(vars.friendly_tag))
            {
                // Send OnSelected signal to Unit / Unitgroup
                hit.transform.gameObject.SendMessage("OnSelected", SendMessageOptions.DontRequireReceiver);

                // Add unit group to selected group
                if (hit.transform.gameObject.tag.Contains(vars.unitgroup_tag))
                {
                    SelectedUnitGroup = hit.transform.gameObject.GetComponent <UnitGroupBase>();
                }
                else // Add unit's group
                {
                    SelectedUnitGroup = hit.transform.gameObject.GetComponent <UnitBase>().unitGroup;
                }
            }
        }
    }
Exemplo n.º 2
0
    // adds a unit group(on retreat)
    public void addUnitGroup(UnitGroupBase group)
    {
        SavedUnitGroup newUnitGroup = new SavedUnitGroup();

        newUnitGroup.position = new Vector3(transform.position.x + 5, transform.position.y, transform.position.z);
        newUnitGroup.unitGroupName = group.name;
        newUnitGroup.attackspeed = group.attackspeed;
        newUnitGroup.movementspeed = group.movementspeed;

        newUnitGroup.damage = group.damage;
        newUnitGroup.health = group.health;
        newUnitGroup.regeneration = group.regeneration;

        newUnitGroup.attackrange = group.attackrange;
        newUnitGroup.visionRange = group.visionRange;

        newUnitGroup.numUnits = group.numUnitsInGroup;
        unitGroupsSaved.Add (newUnitGroup);
    }
Exemplo n.º 3
0
 public void setUnitGroup(UnitGroupBase newUnitGroup)
 {
     unitGroup = newUnitGroup;
 }
Exemplo n.º 4
0
    // Handle unit selection
    private void unitSelection()
    {
        if (SelectedUnitGroup != null)
        {
            SelectedUnitGroup.SendMessage("OnUnselected", SendMessageOptions.DontRequireReceiver);
            SelectedUnitGroup = null;
        }
        // Cast ray to see if object hit is selectable
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;
        if (Physics.Raycast(ray, out hit))
        {
            if (hit.transform.gameObject.tag.Contains(vars.selectable_tag) &&
                hit.transform.gameObject.tag.Contains(vars.friendly_tag))
            {
                // Send OnSelected signal to Unit / Unitgroup
                hit.transform.gameObject.SendMessage("OnSelected", SendMessageOptions.DontRequireReceiver);

                // Add unit group to selected group
                if (hit.transform.gameObject.tag.Contains(vars.unitgroup_tag))
                {
                    SelectedUnitGroup = hit.transform.gameObject.GetComponent<UnitGroupBase>();
                }
                else // Add unit's group
                {
                    SelectedUnitGroup = hit.transform.gameObject.GetComponent<UnitBase>().unitGroup;
                }
            }
        }
    }
Exemplo n.º 5
0
 public void setUnitGroup(UnitGroupBase newUnitGroup)
 {
     unitGroup = newUnitGroup;
 }