Ejemplo n.º 1
0
    private void SquadEditorUpdate()
    {
        if (!Input.GetMouseButton(0))
        {
            return;
        }

        if (cursorInfo.transform != null && UICamera.hoveredObject == null)
        {
            tile = cursorInfo.transform.GetComponent <Tile>();

            if (tile != null)
            {
                //TODO: Allow multiple altitudes OR just make a damn lookup table.
                if (chosenSquadType.staticData.altitude != tile.node.terrain.staticData.altitude)
                {
                    return;
                }

                if (tile.node.obstruction == null)
                {
                    SquadInstance.Create(tile.node, chosenSquadType);
                }
                else if (tile.node.obstruction.GetComponent <SquadInstance>().type != chosenSquadType)
                {
                    SquadInstance.Replace(tile.node.obstruction.GetComponent <SquadInstance>(), chosenSquadType);
                }
            }
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Creates a new SquadInstance
    /// </summary>
    /// <param name="node">The board node the </param>
    /// <param name="squadType"></param>
    /// <returns></returns>
    public static SquadInstance Create(Node node, SquadType squadType)
    {
        if (node.obstruction != null)
        {
            throw new System.Exception("SquadInstance.Create() was called on a non-null terrain node's obstruction. Use SquadInstance.Replace() instead.");
        }

        GameObject go = GameObject.Instantiate(
            squadType.prefab,
            node.position,
            Quaternion.identity
            ) as GameObject;


        SquadInstance squadInstance = go.AddGetComponent <SquadInstance>();

        squadInstance.type = squadType;

        squadInstance.selectable = go.AddGetComponent <Selectable>();

        squadInstance.abilityContainer        = new AbilityContainer();
        squadInstance.abilityContainer.caster = squadInstance.selectable;
        foreach (Ability a in squadType.staticData.abilities)
        {
            squadInstance.abilityContainer.add(a);
        }
        go.name = squadType.staticData.name;

        return(squadInstance);
    }
Ejemplo n.º 3
0
    public static void Replace(SquadInstance squadInstance, SquadType newType)
    {
        Node n = Board.instance.getNode(squadInstance.transform.position);

        if (n == null)
        {
            Debug.LogError("The squadInstance you are trying to replace is not within the bounds of the Board. Something dun messed up.");
            return;
        }

        squadInstance.kill();
        n.obstruction = null;
        Create(n, newType);
    }
Ejemplo n.º 4
0
    void generateNodes()
    {
        //Debug.Log( width );
        //Debug.Log( length );

        TerrainType terra = TypeContainer <TerrainType> .get("Plain");

        //Debug.Log( "TERRAIN TYPE OF TERRA IS " + terra.staticDataame );

        Node n;

        for (int x = 0; x < width; x++)
        {
            for (int z = 0; z < length; z++)
            {
                n           = new Node(terra, new Vector3(x, 0f, z));
                nodes[x, z] = n;
            }
        }


        for (int x = 0; x < width; x++)
        {
            for (int z = 0; z < length; z++)
            {
                n = getNodeUnsafely(x, z);

                n.AssignEdges();
                n.terrain.autoWall();

                if (z == 0 || z == length - 1)
                {
                    SquadInstance.Create(getNodeUnsafely(x, z), TypeContainer <SquadType> .get("placeholder squad"));
                }
            }
        }
    }
Ejemplo n.º 5
0
    public static void Replace(SquadInstance squadInstance, SquadType newType)
    {
        Node n = Board.instance.getNode( squadInstance.transform.position );
        if (n == null)
        {
            Debug.LogError( "The squadInstance you are trying to replace is not within the bounds of the Board. Something dun messed up." );
            return;
        }

        squadInstance.kill();
        n.obstruction = null;
        Create( n, newType );
    }