예제 #1
0
    private void InstallAt(World world, World.Coord coord)
    {
        //world.InstallAt(this, coord);
        //Spawn(world, new Vector2(coord.x, coord.y));

        foreach (IEmitterListener listener in listeners)
        {
            if (listener is IEntityBuildingListener)
            {
                ((IEntityBuildingListener)listener).InstallAt(world, coord);
            }
        }

        foreach (Tile neighbour in Tile.GetNeighbours())
        {
            neighbour.OnNeighbourChanged(world, Tile);
        }
    }
예제 #2
0
    public void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Vector2     pos   = MouseToVector2(Input.mousePosition);
            World.Coord coord = MouseToCoordinate(Input.mousePosition);
            switch (world.selectedMode)
            {
            case World.WorldMode.None:

                EntityComponent entityComponent = GetEmitterAt(pos);
                if (entityComponent != null)
                {
                    world.Selected = entityComponent.Emitter;
                    // TODO: move selector marker following this entity
                }
                else
                {
                    try
                    {
                        world.selectedTile = world.GetTileAt(pos);
                    } catch
                    {
                    }
                    // TODO: move marker at this position
                }
                break;

            case World.WorldMode.Build:
                world.ScheduleJob(EntityRegistry.jobRegistry["construct_building"],
                                  new object[] { world.modeArgs[0], coord }
                                  );
                break;
            }
        }
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            world.SetMode(World.WorldMode.None, null);
        }
    }
예제 #3
0
 public abstract void InstallAt(World world, EntityBuilding entity, World.Coord coord);
예제 #4
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown("Next"))
        {
            NextTool();
        }

        if (Input.GetButtonDown("Fire2"))
        {
            World.Coord cursorCoord    = WorldComponent.MouseToCoordinate(Input.mousePosition);
            Vector2     cursorPosition = WorldComponent.MouseToVector2(Input.mousePosition);
            switch (creativeTool)
            {
            case CreativeTool.PlaceWall:
                worldController.World.InstallAt(EntityRegistry.InstantiateEntityBuilding("wall"), cursorCoord);
                break;

            case CreativeTool.PlaceDoor:
                worldController.World.InstallAt(EntityRegistry.InstantiateEntityBuilding("door"), cursorCoord);
                break;

            case CreativeTool.SpawnCharacter:
                worldController.World.Spawn(EntityRegistry.InstantiateCharacter(), cursorPosition);
                break;

            case CreativeTool.MoveSelected:
                EntityAnimated entityAnimated = worldController.World.GetCharacter("Jim");
                entityAnimated.StartMovingTo(cursorPosition);

                GameObject   go = new GameObject();
                LineRenderer lr = go.AddComponent <LineRenderer>();

                LinkedList <Tile> path = entityAnimated.path;
                if (path == null)
                {
                    break;
                }

                Vector3[] pos = new Vector3[path.Count];
                int       I   = 0;
                foreach (Tile tile in path)
                {
                    //Debug.Log(tile.coord.ToVector2());
                    pos[I++] = (Vector3)tile.coord.ToVector2() - 0.02f * Vector3.forward;
                }
                lr.numPositions    = path.Count;
                lr.widthMultiplier = 0.05f;
                lr.SetPositions(pos);
                lr.material = new Material(Shader.Find("Diffuse"));


                break;

            case CreativeTool.Despawn:
                worldController.World.Uninstall(cursorCoord);
                break;

            default:
                break;
            }
        }
    }
예제 #5
0
 public Tile GetNeighbour(World.Coord direction, bool canBeNull = true)
 {
     return(world.GetTileAtOrNull(coord + direction));
 }
예제 #6
0
 public Tile(World world, World.Coord coord)
 {
     this.world = world;
     this.coord = coord;
 }
예제 #7
0
 public override void InstallAt(World world, EntityBuilding entity, World.Coord coord)
 {
 }
예제 #8
0
 public void InstallAt(World world, World.Coord coord)
 {
     SetEntitySprite(world);
 }
예제 #9
0
 public override void InstallAt(World world, EntityBuilding entity, World.Coord coord)
 {
     //EntityComponent entityComponent = EntityComponent.SpawnEntityControllerInWorld(this, entity, coord);
     //entity.Connect(entityComponent);
 }