Пример #1
0
        public static void CreateParticle(Vector2 position, GSCharacter character)
        {
            GameObject go = Instantiate(PrefabStore.store.cubeParticle);

            go.GetComponent <CubeParticle> ().Initialize(character);
            go.transform.position = position;
        }
Пример #2
0
 public static void CreateParticles(Vector2 position, GSCharacter character, int count)
 {
     for (int i = 0; i < count; i++)
     {
         CreateParticle(position, character);
     }
 }
Пример #3
0
        public void RegisterCharacter(GSCharacter character)
        {
            if (this.character == null)
            {
                this.character = character;

                Initialize();

                SetupUI();
            }
        }
Пример #4
0
        public void Initialize(GSCharacter character, int damage, Vector2 position, Vector2 velocity, int radius = 0)
        {
            this.character = character;
            this.damage    = damage;
            this.radius    = radius;

            transform.position = position;

            GetComponent <Rigidbody2D> ().velocity = velocity;

            StartCoroutine(DestroyAfterTime(10));
        }
Пример #5
0
        public static void ExplodeInAllGrid(GSCharacter character, Vector2 position, int radius, int damage)
        {
            foreach (Gridlike.Grid grid in Gridlike.Grid.GetAllGrids())
            {
                GSGrid wrapper = grid.GetComponent <GSGrid> ();

                if (wrapper != null)
                {
                    wrapper.Explosion(character, position, radius, damage);
                }
                else
                {
                    Debug.LogWarning("Grid has no GSGrid");
                }
            }
        }
Пример #6
0
        public void Damage(GSCharacter character, int x, int y, int damage, Vector2 position)
        {
            Tile tile = grid.Get(x, y);

            if (tile != null)
            {
                GSTileBehaviour behaviour = grid.GetTileComponent(x, y) as GSTileBehaviour;
                int             id        = tile.id;
                int             HP        = (int)tile.state1;

                if (behaviour != null)
                {
                    id = behaviour.tile.id;
                    x  = behaviour.x;
                    y  = behaviour.y;

                    HP = (int)grid.Get(x, y).state1;
                }

                if (GSConsts.TileExists(id))
                {
                    int hpLost;

                    if (HP + damage >= GSConsts.tiles [id].HP)
                    {
                        hpLost = Mathf.Min(damage, GSConsts.tiles [id].HP - HP);
                        grid.Clear(x, y);
                    }
                    else
                    {
                        hpLost = damage;
                        grid.SetState(x, y, HP + damage, 0, 0);
                    }

                    if (position == Vector2.zero)
                    {
                        position = grid.TileCenterInWorld(x, y);
                    }

                    CubeParticle.CreateParticles(position, character, Mathf.CeilToInt(hpLost * GSConsts.tiles [id].cubePerHP));
                }
                else
                {
                    grid.Clear(x, y);
                }
            }
        }
Пример #7
0
        public void Explosion(GSCharacter character, Vector2 position, int radius, int damage)
        {
            int x;
            int y;

            grid.WorldToGrid(position, out x, out y);

            for (int i = x - radius; i <= x + radius; i++)
            {
                for (int j = y - radius; j <= y + radius; j++)
                {
                    int dx = i - x;
                    int dy = j - y;

                    if (dx * dx + dy * dy <= radius * radius)
                    {
                        Damage(character, i, j, damage, grid.TileCenterInWorld(i, j));
                    }
                }
            }
        }
Пример #8
0
 public void _Inject(GSCharacter character)
 {
     this.character = character;
 }
Пример #9
0
 public void Initialize(GSCharacter character)
 {
     target    = character;
     startTime = Time.time;
     speed     = 10 * Random.insideUnitCircle;
 }
Пример #10
0
		public void _Inject(GSCharacter character, GSShip ship) {
			this.character = character;
			this.ship = ship;
		}