private void Awake()
    {
        tileHandler  = MyFunc.GetObject(MyFunc.ObjType.TILE_CONTAINER).GetComponent <TileHandler>();
        detectedTile = new TileHandler.TileInfo();

        isChest = false;
    }
Example #2
0
    //Places a tile in a pos x,y relative to the top left corner of the screen
    private void PlaceTile(string tileType, int x, int y, Vector3 worldStartPos)
    {
        int         tileIndex = Convert.ToInt32(tileType, 16); //Hex to int
        TileHandler newTile   = Instantiate(tilePrefabs[tileIndex]).GetComponent <TileHandler>();

        newTile.Setup(new Point(x, y), new Vector3(worldStartPos.x + (TileSize * x), worldStartPos.y - (TileSize * y), 0), map);
    }
Example #3
0
        void Start()
        {
            // 原版, 保留之前的
//			if (FindObjectsOfType(typeof(TileHandlerHelper)).Length > 1) {
//				Debug.LogError ("There should only be one TileHandlerHelper per scene. Destroying.");
//				Destroy (this);
//				return;
//			}

            // 删除之前的TileHandler, 便于采用最新Graph
            var objs = FindObjectsOfType(typeof(TileHandlerHelper));

            if (objs.Length > 1)
            {
                for (int i = 0; i < objs.Length; i++)
                {
                    if (objs[i] != this)
                    {
                        Destroy(objs[i]);
                    }
                }
            }

            if (handler == null)
            {
                if (AstarPath.active == null || AstarPath.active.astarData.recastGraph == null)
                {
                    Debug.LogWarning("No AstarPath object in the scene or no RecastGraph on that AstarPath object");
                }

                handler = new TileHandler(AstarPath.active.astarData.recastGraph);
                handler.CreateTileTypesFromGraph();
            }
        }
Example #4
0
    public void InitBeam(GameHandler h, Vector3 start, Vector3 dir, BeamHandler template)
    {
        if (beamCount >= MAX_BEAMS)
        {
            GameObject.Destroy(gameObject);
            return;
        }
        this.intensity = (template != null) ? template.intensity : 10;

        beamCount++;

        this.game = h;

        transform.rotation = Quaternion.FromToRotation(Vector3.right, dir);
        transform.position = start;

        this.start = 0;
        this.end   = 0;


        this.powered = true;

        this.endPoint = null;
        this.children = null;

        this.sprayEffect = game.CreateSprayEffect();

        layerMask =
            1 << LayerMask.NameToLayer("Tile") |
                1 << LayerMask.NameToLayer("Wall");

        SetEndpoints();
    }
Example #5
0
    public void SendToPlayer(TileHandler tile)
    {
        // Lakhbir


        player.SelectionHandler(tile);
    }
	void Awake()
	{
		if (tileHandler != null)
		{
			GameObject.Destroy(tileHandler);
		}
		else
		{
			tileHandler = this;
		}


		TileSheetData = new TileSheet(tileSheet, resolution);

		tiles      = new Tile[TileSheet.totalTiles];
		tilePixels = new Color[TileSheet.totalTiles][];

		for (int i = 0; i < tiles.Length; ++i)
		{
			tiles[i]      = new Tile(i, tileCollisionType[i]);
			tilePixels[i] = TileSheetData[i];
		}

		EmptyTile = tiles.Length - 1;
	}
Example #7
0
    void Start()
    {
        tiles = GetComponent <TileHandler>();
        int tileID   = 0;
        int columnID = 0;

        id = netId;
        foreach (var v in validTiles)
        {
            v.ID         = tileID++;
            v.HeldColumn = columnID++;
            if (columnID > 5)
            {
                columnID = 0;
            }
            v.owningPlayer = (int)id.Value;
            v.Confirm     += CreateUnitAtTile;
            v.Selected    += ToggleTile;
        }
        cam = GetComponentInChildren <Camera>();
        if (!isLocalPlayer)
        {
            cam.enabled = false;
            cam.GetComponent <AudioListener>().enabled = false;
        }
    }
Example #8
0
 public Hexagon(TileType tile, Direction dir, Pos p, TileHandler t)
 {
     this.tile = tile;
     this.dir  = dir;
     obj       = MonoBehaviour.Instantiate(t.tiles[(int)tile],
                                           Transformer.PosToWorld(p), Quaternion.AngleAxis(DirectionToDegree(dir), Vector3.back)) as GameObject;
 }
Example #9
0
        /// <inheritdoc />
        public IObservable <int> Get(Tile tile, IList <IObserver <MapData> > observers)
        {
            TileHandler tileHandler = new TileHandler(tile, _materialProvider, observers, _trace);

            return(Get(tile, tile.GetHashCode(), tileHandler.OnMeshBuiltHandler,
                       tileHandler.OnElementLoadedHandler, OnErrorHandler));
        }
Example #10
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            screenWidth  = graphics.PreferredBackBufferWidth;
            screenHeight = graphics.PreferredBackBufferHeight;

            mainTarget = DefaultTarget;

            tileTarget     = DefaultTarget;
            entityTarget   = DefaultTarget;
            postTileTarget = DefaultTarget;
            screenTarget   = DefaultTarget;

            drawingTarget = DefaultTarget;

            random = new Random();


            cameraPosition = Point.Zero;

            mousePos = new Point();

            TextureHandler.Initialize();

            GameID.Initialize();

            NpcHandler.Initialize();
            LevelHandler.Initialize();
            TileHandler.Initialize();

            base.Initialize();
        }
Example #11
0
 void Start()
 {
     _mapEditor   = GetComponent <MapEditor>();
     _tileHandler = GetComponent <TileHandler>();
     _uiHandler   = GetComponent <UIHandler>();
     _playerMove  = _mapEditor.Player.GetComponent <PlayerMove>();
 }
Example #12
0
        public void GetTileWithRtcCenterTest()
        {
            // arrange
            var instances = new List <Instance>();
            var instance  = new Instance();

            instance.Position = new Wkx.Point(1, 2);
            instance.Model    = "box.glb";
            instances.Add(instance);

            var instance1 = new Instance();

            instance1.Position = new Wkx.Point(10, 20);
            instance1.Model    = "box.glb";
            instances.Add(instance1);

            // act
            var tile = TileHandler.GetTile(instances, UseRtcCenter: true);
            var i3dm = I3dmReader.Read(new MemoryStream(tile.tile));

            // assert
            Assert.IsTrue(tile.isI3dm == true);
            Assert.IsTrue(tile.tile.Length > 0);
            Assert.IsTrue(i3dm.Positions.Count == 2);
            Assert.IsTrue(i3dm.Positions[0] == new Vector3(0, 0, 0));
            Assert.IsTrue(i3dm.Positions[1] == new Vector3(9, 18, 0));
            Assert.IsTrue(i3dm.RtcCenter == new Vector3(1, 2, 0));
        }
Example #13
0
    void Awake()
    {
        if (tileHandler != null)
        {
            GameObject.Destroy(tileHandler);
        }
        else
        {
            tileHandler = this;
        }


        TileSheetData = new TileSheet(tileSheet, resolution);

        tiles      = new Tile[TileSheet.totalTiles];
        tilePixels = new Color[TileSheet.totalTiles][];

        for (int i = 0; i < tiles.Length; ++i)
        {
            tiles[i]      = new Tile(i, tileCollisionType[i]);
            tilePixels[i] = TileSheetData[i];
        }

        EmptyTile = tiles.Length - 1;
    }
Example #14
0
    //Draws the generated path
    // Update is called once per frame
    //void Update () {
    //       ClickTile();
    //       if(Input.GetKeyDown(KeyCode.Space))
    //       {
    //           AStar.GetPath(start.GridPos, goal.GridPos);
    //       }
    //}

    private void ClickTile()
    {
        if (Input.GetMouseButtonDown(2))
        {
            RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
            if (hit.collider != null)
            {
                TileHandler tmp = hit.collider.GetComponent <TileHandler>();
                if (tmp != null)
                {
                    if (start == null)
                    {
                        start = tmp;
                        start.SpriteRenderer.sprite = sprite;
                        start.SpriteRenderer.color  = Color.green;
                    }
                    else if (goal == null)
                    {
                        goal = tmp;
                        goal.SpriteRenderer.sprite = sprite;

                        goal.SpriteRenderer.color = Color.red;
                    }
                }
            }
        }
    }
Example #15
0
        public void GetTileWithScaleNonUniformTest()
        {
            // arrange
            var scaleNonuniform = new double[3] {
                1, 2, 3
            };
            var instances = new List <Instance>();
            var instance  = new Instance();

            instance.Position        = new Wkx.Point(1, 2);
            instance.ScaleNonUniform = scaleNonuniform;
            instance.Model           = "box.glb";
            instances.Add(instance);

            // act
            var tile = TileHandler.GetTile(instances, UseScaleNonUniform: true);
            var i3dm = I3dmReader.Read(new MemoryStream(tile.tile));

            // assert
            Assert.IsTrue(tile.isI3dm == true);
            Assert.IsTrue(tile.tile.Length > 0);
            Assert.IsTrue(i3dm.Positions.Count == 1);
            Assert.IsTrue(i3dm.GlbData.Length > 0);
            Assert.IsTrue(i3dm.ScaleNonUniforms[0] == new Vector3((float)scaleNonuniform[0], (float)scaleNonuniform[1], (float)scaleNonuniform[2]));
        }
Example #16
0
    public bool move(TilemapHandler tmh, Vector2Int to)
    {
        if (tooFarAway(to))
        {
            return(false);
        }

        kicksBall = false;

        TileHandler onTile = TilemapHandler.getTile(tilePositionOrigin.x, tilePositionOrigin.y).GetComponent <TileHandler>();

        if (TilemapHandler.getTile(to).GetComponent <TileHandler>().getCharacter() != null)
        {
            if ((to - tilePositionOrigin).y == 0)
            {
                to += Vector2Int.right * (((to - tilePositionOrigin).x < 0) ? -1 : 1);
            }
            else
            {
                to += Vector2Int.up * (((to - tilePositionOrigin).y < 0) ? -1 : 1);
            }
        }

        tmh.moveCharacter(tilePosition, to);

        if (hasBall = onTile.getHasBall())
        {
            GameObject.Find("Ball").GetComponent <BallController>().owner = transform;
            GameObject.Find("Ball").transform.position = transform.position - new Vector3(0, 0.5f);
        }

        return(true);
    }
Example #17
0
 public void SpawnObstacle(TileHandler Tile)
 {
     if (Tile.Tile.transform.FindChild("ObstacleGeneration") != null)
     {
         SpawnObstacle(Tile.Tile.transform.FindChild("ObstacleGeneration"));
     }
 }
Example #18
0
        void Start()
        {
            if (FindObjectsOfType(typeof(TileHandlerHelper)).Length > 1)
            {
                EB.Debug.LogError("There should only be one TileHandlerHelper per scene. Destroying.");
                Destroy(this);
                return;
            }

#if BNICKSON_UPDATED
            CreateTileHandler();

            instance = this;
#else
            if (handler == null)
            {
                if (AstarPath.active == null || AstarPath.active.astarData.recastGraph == null)
                {
                    EB.Debug.LogWarning("No AstarPath object in the scene or no RecastGraph on that AstarPath object");
                }

                handler = new TileHandler(AstarPath.active.astarData.recastGraph);
                handler.CreateTileTypesFromGraph();
            }
#endif
        }
Example #19
0
    /// <summary>
    /// Return true if this piece can capture the other one located in
    /// a given position + offset.
    /// </summary>
    protected override bool CanCapture(int offsetX, int offsetY, IntVector2 pos)
    {
        if (base.board.WithinBounds(pos.x + offsetX, pos.y + offsetY))
        {
            TileHandler nextTile =
                base.board.GetTile(pos.x + offsetX, pos.y + offsetY);

            /**
             * See if:
             * The nextTile is occupied.
             * Has a enemy Piece in there.
             * the enemy has NOT been captured yet.
             * and the following tile is within bounds.
             */
            if (nextTile.transform.childCount != 0 &&
                nextTile.transform.GetChild(0).CompareTag(enemy_tag) &&
                !nextTile.transform.GetChild(0).GetComponent <Piece>().HasBeenCaptured() &&
                base.board.WithinBounds(pos.x + 2 * offsetX, pos.y + 2 * offsetY))
            {
                nextTile =
                    base.board.GetTile(pos.x + 2 * offsetX, pos.y + 2 * offsetY);
                if (nextTile.transform.childCount == 0)
                {
                    return(true);
                }
            }
        }

        return(false);
    }
Example #20
0
    public void SelectPiece(Piece selectedPiece, ArrayList possibleMovements)
    {
        paintedPositions = new ArrayList();
        paintedPositions.Add(selectedPiece.GetPosition());

        // Play the sound.
        if (sound != null)
        {
            audioSource.PlayOneShot(sound);
        }

        // Change selected tile's color.

        if (CheckersMultiplayer.Instance.IsTableTen)
        {
            TileHandler tile = GetTile(selectedPiece.GetPosition());

            if (tile.GetComponent <TileHandler>().GetComponent <Image>().color != redLineColor)
            {
                tile.GetComponent <TileHandler>().IsRed = false;
            }

            else
            {
                tile.GetComponent <TileHandler>().IsRed = true;
            }
            tile.GetComponent <Image>().color = selectionColor;
            foreach (Movement movement in possibleMovements)
            {
                paintedPositions.Add(movement.getDestinyPosition());
                if (GetTile(movement.getDestinyPosition()).GetComponent <Image>().color != redLineColor)
                {
                    GetTile(movement.getDestinyPosition()).GetComponent <TileHandler>().IsRed = false;
                }
                else
                {
                    GetTile(movement.getDestinyPosition()).GetComponent <TileHandler>().IsRed = true;
                }
                GetTile(movement.getDestinyPosition()).GetComponent <Image>().color = possibiliteColor;
            }
        }
        else
        {
            TileHandler tile = GetTile(selectedPiece.GetPosition());

            tile.GetComponent <Image>().color = selectionColor;
            // Change the color of the avaliable tiles.
            foreach (Movement movement in possibleMovements)
            {
                paintedPositions.Add(movement.getDestinyPosition());
                if (GetTile(movement.getDestinyPosition()).GetComponent <Image>() != null)
                {
                    GetTile(movement.getDestinyPosition()).GetComponent <Image>().color = possibiliteColor;
                }
            }
        }


        // Change the color of the avaliable tiles.
    }
Example #21
0
 public MapLoader(TileHandler tileHandler, GridHandler gridHandler, TilesetLoader tilesetLoader, MapData mapData)
 {
     _tileHandler   = tileHandler;
     _gridHandler   = gridHandler;
     _tilesetLoader = tilesetLoader;
     _mapData       = mapData;
     Reset();
 }
Example #22
0
    /// <summary>
    ///  Set the current position of the piece in the board by the parent tile.
    /// </summary>
    public virtual bool SetCurrentPosition()
    {
        // Get current position.
        TileHandler parentTile = transform.parent.GetComponent <TileHandler>();

        position = new IntVector2(parentTile.getRow(), parentTile.getColumn());
        return(true);
    }
Example #23
0
 private void Start()
 {
     TileHandler          = new TileHandler(ref scene);
     LayerHandler         = new LayerHandler(ref scene);
     ReportHandler        = new ReportHandler();
     TileHandler.Redraw  += OnNeedRedraw;
     LayerHandler.Redraw += OnNeedRedraw;
 }
Example #24
0
 private void Awake()
 {
     tileHandler = MyFunc.GetObject(MyFunc.ObjType.FIXED_OBJECT).
                   transform.Find("Tiles").GetComponent <TileHandler>();
     goldUi    = MyFunc.GetObject(MyFunc.ObjType.PLAYER_UI).GetComponent <GoldUi>();
     unitCount = MyFunc.GetObject(MyFunc.ObjType.PLAYER_UI).GetComponent <UnitCount>();
     inven     = MyFunc.GetObject(MyFunc.ObjType.INVENTORY).GetComponent <Inventory>();
 }
    public void setTile(TileHandler th, Transform tr)
    {
        tile = th;
        transform.SetParent(tr);
        int n = th.numEnemies();

        transform.localPosition = new Vector3(-20 + 10 * n, 0, 0);
    }
Example #26
0
        public void AddTileProperty_IsAddedToDictionary_DictionaryCountIncreases()
        {
            var tileHandler = new TileHandler(new GridHandler(new CameraHandler()));

            tileHandler.AddTileProperty(new TileProperty(0));

            Assert.AreEqual(1, tileHandler.TilePropertyDictionary.Count);
        }
    void Start()
    {
        _mapPlane    = new Plane(Vector3.up, Vector3.zero);
        _tileHandler = GetComponent <TileHandler>();
        _camera      = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>();

        _mode = EditorMode.AddTile;
    }
        private void Start()
        {
            canvas      = FindObjectOfType <Canvas>().gameObject;
            tileHandler = FindObjectOfType <TileHandler>();

            selectionTool.canvas = canvas;
            selectionTool.onSelectionCompleted.AddListener(OnSelectionFunction);
            selectionTool.EnableTool();
        }
Example #29
0
 public void SetupComponents(GoldUi gold_, UnitCount unitCount_, TileHandler tileHandler_)
 {
     gold      = gold_;
     unitCount = unitCount_;
     // 타일 핸들러
     tileHandler  = tileHandler_;
     _squareTiles = tileHandler.squareInstances;
     _hexaTiles   = tileHandler.hexaInstances;
 }
    void Start()
    {
        enemyCount = Random.Range (3,6);
        th = GameObject.Find ("TileHandler").GetComponent<TileHandler> ();
        confirmation = false;
        windowRect = new Rect(Screen.width/2-200, Screen.height/2-100, 400,200);
        SpawnEnemies();

        //		SpawnPlayer ();
    }
Example #31
0
 public void InitGame()
 {
     _world      = new WorldHandler();
     _tile       = new TileHandler();
     _random     = new RandomHandler();
     _hero       = new HeroHandler();
     _generation = new GenerationHandler();
     _spawn      = new Spawner();
     _item       = new ItemHandler();
 }
Example #32
0
    /// <summary>
    /// Return if there is a piece with a given tag in the given position.
    /// </summary>
    private bool HasPieceWithTag(IntVector2 position, string tag)
    {
        TileHandler tile = this.board.GetTile(position);

        if (tile != null && tile.HasChild() && tile.GetChild().CompareTag(tag))
        {
            return(true);
        }
        return(false);
    }
Example #33
0
        public GameState(string name)
            : base(name)
        {
            this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true);

            this._entityHandler = null;
            this._tileHandler = null;
            this.playerObj = null;

            this.Paint += this.PaintEvent;
        }
	public ForestGenerator(MapData mapData)
	{
		this.mapData = mapData;
		tileHandler  = TileHandler.tileHandler;
		mapData.Width  = 80;
		mapData.Height = 80;

		FillMapWithEmptyTile();

		MakeFloor();
	}
		void Start () {
			if (FindObjectsOfType(typeof(TileHandlerHelper)).Length > 1) {
				Debug.LogError("There should only be one TileHandlerHelper per scene. Destroying.");
				Destroy(this);
				return;
			}

			if (handler == null) {
				if (AstarPath.active == null || AstarPath.active.astarData.recastGraph == null) {
					Debug.LogWarning("No AstarPath object in the scene or no RecastGraph on that AstarPath object");
				}

				handler = new TileHandler(AstarPath.active.astarData.recastGraph);
				handler.CreateTileTypesFromGraph();
			}
		}
	public TextureBuilder(MapData map)
	{
		this.map   = map;
		tileHandler = TileHandler.tileHandler;

		this.tiles = tileHandler.TileSheetData;

		int textureWidth  = map.Width  * tileHandler.resolution;
		int textureHeight = map.Height * tileHandler.resolution;

		Texture = new Texture2D(textureWidth, textureHeight);
		BuildTexture();

		Texture.filterMode = FilterMode.Point;
		Texture.wrapMode   = TextureWrapMode.Clamp;

		Apply();
	}
Example #37
0
    public void Start()
    {
        th = GameObject.FindGameObjectWithTag("TileHandler").GetComponent<TileHandler>();
        switch(missionType){

        case MissionType.Elimination:
            Tile tile = th.GetWalkableTile();
            GameObject alien = GameObject.Instantiate(Resources.Load("TargetAlien") as GameObject, tile.transform.position, tile.transform.rotation) as GameObject;
            target = alien.transform;
            break;
        case MissionType.Intel:
            Tile someTile = th.GetWalkableTile();

            GameObject intel = GameObject.Instantiate(Resources.Load("Intel") as GameObject, someTile.transform.position, someTile.transform.rotation) as GameObject;
            target = intel.transform;
            break;
        }
    }
Example #38
0
        public override void Destruct()
        {
            base.Destruct();

            //Destruction of the game state.
            //All resources that were allocated in the construct phase should be disposed of here.
            lock(this.lockObj) {
                if(this._buffer != null) this._buffer.Dispose();
            }

            aTimer.Dispose();

            ((Form1)this.Form).iHandler.ClearKeys();

            this._entityHandler.ClearList();
            this._tileHandler.ClearMap();

            this._entityHandler = null;
            this._tileHandler = null;
            this.playerObj = null;
        }
Example #39
0
        public override void Construct()
        {
            this.aTimer = new Timer();
            aTimer.Tick += new EventHandler(TimerTick);
            aTimer.Interval = 1000;
            aTimer.Start();
            timer = 0;

            //Construction of the game state, anything that the game needs to create initially should be put here (Player, platform, etc).
            lock (this.lockObj) {
                if (this._buffer != null)
                    this._buffer.Dispose();

                this._buffer = new Bitmap(this.Size.Width, this.Size.Height);
            }

            //Finally we make the handlers that are required to do things in the gamestate.
            this._entityHandler = new EntityHandler(this);
            this._tileHandler = new TileHandler(this);

            //Tile loading
            try
            {
                this._tileHandler.LoadFromFile("map_" + level);
            }
            catch (Exception noMoreMaps)
            {
                finishedGame();
                return;
            }

            //Making a new player.
            this.playerObj = new Player(whichStartPoint(level), 0);

            this._entityHandler.AddEntity(playerObj);

            //Sorting the list so we can draw them behind each other.
            this._entityHandler.SortList();

            ((Form1)this.Form).iHandler.addKeyDown(delegate (object sender, KeyEventArgs e) {
                // Switch case to see what handling to do when a button is pressed.
                switch (e.KeyCode) {
                    case Keys.Escape:
                        ((Form1)this.Form).sHandler.activateState("MainState");
                        level = 1;
                        break;
                    case Keys.A:
                        this.playerObj.GoLeft();
                        break;
                    case Keys.D:
                        this.playerObj.GoRight();
                        break;
                    case Keys.W:
                        this.playerObj.GoUp();
                        break;
                    case Keys.Space:
                        this.playerObj.GoUp();
                        break;
                    default:
                        break;
                }
            });
            ((Form1)this.Form).iHandler.addKeyUp(delegate (object sender, KeyEventArgs e) {
                // Switch case to see what handling to do when a button is released.
                switch (e.KeyCode) {
                    case Keys.A:
                        this.playerObj.Stop();
                        break;
                    case Keys.D:
                        this.playerObj.Stop();
                        break;
                }
            });

            this.playerObj.Alive = true;

            base.Construct();
        }
		/** Use the specified handler, will create one at start if not called */
		public void UseSpecifiedHandler (TileHandler handler) {
			this.handler = handler;
		}