Базовый класс для всех игровых объектов
Inheritance: CocosSharp.CCSprite
コード例 #1
0
ファイル: Gate.cs プロジェクト: Insality/essence-of-shadows
        public override void Collision(Entity other) {
            base.Collision(other);

            if (other.Tag == Tags.Player) {
                (other as Player).AccState.SwitchLocation(TeleportTo);
            }
        }
コード例 #2
0
        /** owner - ссылается на объект, кто создавал эмитер. Если указан, эмитер следует за ним*/

        public static CCParticleSystem GetEmiter(string texture, ParticleType type, int dieAfter, CCPoint where,
            Entity owner = null) {
            CCPoint pos;
            if (owner != null)
                pos = new CCPoint(owner.Texture.PixelsWide/2, owner.Texture.PixelsHigh/2);
            else
                pos = where;


            CCParticleSystem emiter = new CCParticleMeteor(pos);

            switch (type) {
                case ParticleType.ProjectileTrail:
                    emiter = new CCParticleMeteor(pos) {
                        Scale = 0.1f,
                        SpeedVar = 250,
                        Texture = CCTextureCache.SharedTextureCache.AddImage(texture)
                    };
                    if (owner != null)
                        emiter.Gravity = Entity.GetNormalPointByDirection(owner.Direction)*-2000;

                    break;
                case ParticleType.LevelUp:
                    emiter = new CCParticleSun(pos) {
                        Scale = 0.1f,
                        SpeedVar = 150,
                        Texture = CCTextureCache.SharedTextureCache.AddImage(texture)
                    };
                    break;
            }

            emiter.ScheduleOnce((float x) => emiter.RemoveFromParent(), dieAfter);

            return emiter;
        }
コード例 #3
0
        public override void Collision(Entity other) {
            base.Collision(other);

            if (other.Tag == Tags.Player) {
                (other as Player).AccState.Gold += 100;
                Remove();
            }
        }
コード例 #4
0
        private void SpawnBoss() {
            Entity boss = null;
            switch (_gameLayer.Location) {
                case Locations.Desert:
                    boss = new Emperor(Util.GetUniqueId());
                    break;
                case Locations.City:
                    boss = new Cardinal(Util.GetUniqueId());
                    break;
                case Locations.Cave:
                    boss = new Mossorus(Util.GetUniqueId());
                    var boss2 = new Interitus(Util.GetUniqueId()) {
                        Position = new CCPoint(_gameLayer.MapSize().Width, _gameLayer.MapSize().Height),
                    };
                    _gameLayer.AddEntity(boss2);
                    break;
                default:
                    Log.Print("DO nothing at SpawnBoss");
                    break;
            }

            if (boss != null) {
                boss.Position = new CCPoint(_gameLayer.MapSize().Width, _gameLayer.MapSize().Height);
                _gameLayer.AddEntity(boss);
                _boss = boss;
            }
        }