Inheritance: IExecuteSystem, ISetPool
示例#1
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        print("Touching Object");

        moveSystem = collision.gameObject.GetComponent <MoveSystem>();
        //wireScript = collision.gameObject.GetComponent<WireScript>();

        if (moveSystem != null)
        {
            if (moveSystem.isAlwaysPowered == true || moveSystem.isPowered == true)
            {
                print("POWERED!!!!");
                isPowered = true;
            }
        }
    }
示例#2
0
    private void Awake()
    {
        entities        = new List <Entity>();
        newEntities     = new Queue <Entity>();
        expiredEntities = new Queue <Entity>();

        entitySystem     = new EntitySystem(this);
        inputSystem      = new InputSystem(this);
        moveSystem       = new MoveSystem(this);
        controllerSystem = new ControllerSystem(this);
        gunSystem        = new GunSystem(this);
        bulletSystem     = new BulletSystem(this);
        buffSystem       = new BuffSystem(this);
        aiSystem         = new AISystem(this);
        levelSystem      = new LevelSystem(this);
    }
    private void OnTriggerStay2D(Collider2D collision)
    {
        print("Touching Object");

        moveSystem = collision.gameObject.GetComponent <MoveSystem>();
        wireScript = collision.gameObject.GetComponent <WireScript>();

        if (moveSystem != null)
        {
            if (moveSystem.isPowered == true)
            {
                print("POWERED!!!!");
                animator.SetBool("isActive", true);
                isPowered = true;
            }
        }
    }
        protected override void Initialize()
        {
            this.IsMouseVisible = true;
            //Get Systems
            RenderSystem           = SystemManager.Instance.GetSystem <RenderSystem>();
            LoadContentSystem      = SystemManager.Instance.GetSystem <LoadContentSystem>();
            InputHandlerSystem     = SystemManager.Instance.GetSystem <InputHandler>();
            TankMovementSystem     = SystemManager.Instance.GetSystem <TankMovementSystem>();
            TitlesafeRenderSystem  = SystemManager.Instance.GetSystem <TitlesafeRenderSystem>();
            CollisionSystem        = SystemManager.Instance.GetSystem <CollisionSystem>();
            CameraFollowSystem     = SystemManager.Instance.GetSystem <CameraSceneSystem>();
            LightSystems           = SystemManager.Instance.GetSystem <FlashlightSystem>();
            MoveSystem             = SystemManager.Instance.GetSystem <MoveSystem>();
            CollisionResolveSystem = SystemManager.Instance.GetSystem <CollisionResolveSystem>();
            WallCollisionSystem    = SystemManager.Instance.GetSystem <WallCollisionSystem>();
            AISystem              = SystemManager.Instance.GetSystem <AISystem>();
            EnemyCollisionSystem  = SystemManager.Instance.GetSystem <EnemyCollisionSystem>();
            AnimationSystem       = SystemManager.Instance.GetSystem <AnimationSystem>();
            SoundSystem           = SystemManager.Instance.GetSystem <SoundSystem>();
            WeaponSystem          = SystemManager.Instance.GetSystem <WeaponSystem>();
            BulletCollisionSystem = SystemManager.Instance.GetSystem <BulletCollisionSystem>();
            HealthSystem          = SystemManager.Instance.GetSystem <HealthSystem>();

            TempGameEnder = new TempGameEnder();

            //Init systems that require initialization
            TankMovementSystem.Start();
            WallCollisionSystem.Start();
            SoundSystem.Start();
            WeaponSystem.Start();
            EnemyCollisionSystem.Start();
            BulletCollisionSystem.Start();

            _gameDependencies.GameContent = this.Content;
            _gameDependencies.SpriteBatch = new SpriteBatch(GraphicsDevice);
            // just quickly done for FPS testing
            spriteBatch            = _gameDependencies.SpriteBatch;
            _gameDependencies.Game = this;

            CreateTestEntities();

            base.Initialize();
        }
示例#5
0
    public static List <ISystem> GetListOfSystems()
    {
        // determine order of systems to add
        List <ISystem> toRegister = new List <ISystem>();

        // AJOUTEZ VOS SYSTEMS ICI
        CreationSystem  createSyst    = new CreationSystem();
        MoveSystem      moveSyst      = new MoveSystem();
        FrameTimeSystem frameTimeSyst = new FrameTimeSystem();
        RollBackSystem  rollBackSyst  = new RollBackSystem();
        TurboSystem     turboSyst     = new TurboSystem();

        toRegister.Add(createSyst);
        toRegister.Add(moveSyst);
        toRegister.Add(turboSyst);
        toRegister.Add(frameTimeSyst);
        toRegister.Add(rollBackSyst);

        return(toRegister);
    }
示例#6
0
        private void InitSystems(RenderTarget target)
        {
            DisplaySystem displaySystem = new DisplaySystem(target);

            systems.Add(displaySystem);

            MoveSystem moveSystem = new MoveSystem();

            systems.Add(moveSystem);

            CollisionSystem collisionSystem = new CollisionSystem(target);

            systems.Add(collisionSystem);

            ThrowingSystem throwingSystem = new ThrowingSystem();

            systems.Add(throwingSystem);

            DilayedStartSystem dilayedStartSystem = new DilayedStartSystem();

            systems.Add(dilayedStartSystem);
        }
示例#7
0
    void Awake()
    {
        _world = new World();
        var archeType = _world.ArcheTypeManager.GetOrCreateArcheType(typeof(PositionData), typeof(RotationData));
        var xOrigin   = -(Width * 0.5f);
        var yOrigin   = -(Height * 0.5f);

        for (int y = 0; y < Height; ++y)
        {
            for (int x = 0; x < Width; ++x)
            {
                var entity = _world.EntityManager.Create(archeType);
                _world.EntityManager.SetComponentData <PositionData>(entity, new PositionData()
                {
                    pos = new Vector3(xOrigin + x, 0, yOrigin + y)
                });
                _world.EntityManager.SetComponentData <RotationData>(entity, new RotationData()
                {
                    rot = Quaternion.identity
                });
            }
        }
        _matrices                          = new Matrix4x4[ObjectCount];
        _moveSystem                        = new MoveSystem(_world.ArcheTypeManager.GetOrCreateArcheType(typeof(PositionData)));
        _makeMatrixSystem                  = new MakeMatrixSystem(archeType);
        _makeMatrixSystem.Matrices         = _matrices;
        _makeMatrixSystem.MatricesSegments = _matricesSegments;

        int count = ObjectCount;

        while (count > 0)
        {
            var len     = Mathf.Min(count, 1023);
            var segment = new Matrix4x4[len];
            _matricesSegments.Add(segment);
            count -= len;
        }
    }
示例#8
0
    void Start()
    {
        if (Camera.main == null)
        {
            GameObject go = new GameObject("Camera");
            mainCamera = go.AddComponent <Camera>();
        }
        else
        {
            mainCamera = Camera.main;
        }
        mainCamera.clearFlags       = CameraClearFlags.Color;
        mainCamera.backgroundColor  = Color.black;
        mainCamera.orthographic     = true;
        mainCamera.orthographicSize = 1f;
        mainCamera.nearClipPlane    = 0f;

        screenRect = Rect.MinMaxRect(-mainCamera.aspect, -1f, mainCamera.aspect, 1f);

        entitys       = new DList <Entity>();
        playerEntitys = new DList <MoveAbleEntity>();
        speeds        = new DList <SpeedComponent>();
        eatings       = new DList <EatingComponent>();

        entitySystem     = new EntitySystem(this);
        moveSystem       = new MoveSystem(this);
        gameObjectSystem = new GameObjectSystem(this);

        inputSystem = new InputSystem(this);

        eatSystem        = new EatSystem(this);
        eatingSystem     = new EatingSystem(this);
        circlePushSystem = new CirclePushSystem(this);

        entitySystem.InitScene();
        ApplyDelayCommands();//执行延迟增删数组内容的操作
    }
示例#9
0
        protected override void Initialize()
        {
            var displaySize = this.graphics.GraphicsDevice.DisplayMode.TitleSafeArea;

            this.graphics.PreferredBackBufferHeight = displaySize.Height - 100;
            this.graphics.PreferredBackBufferWidth  = displaySize.Width;
            this.graphics.ApplyChanges();

            const int minX = 0;
            var       maxX = this.graphics.PreferredBackBufferWidth;
            const int minY = 0;
            var       maxY = this.graphics.PreferredBackBufferHeight;

            this.moveSystem             = new MoveSystem(this.graphics, Scene.EntityCount, Scene.PositionComponents, Scene.VelocityComponents);
            this.velocityModifierSystem = new VelocityModifierSystem(Scene.EntityCount, Scene.VelocityModifierCount, Scene.PositionComponents,
                                                                     Scene.VelocityConstraintComponents, Scene.VelocityComponents, Scene.SizeComponents, Scene.VelocityModifierComponents);

            var random = new Random();

            for (int i = 0; i < Scene.EntityCount; i++)
            {
                var position = new PositionComponent();
                position.Value = new Vector2(random.Next(minX, maxX), random.Next(minY, maxY));
                Scene.PositionComponents[i] = position;

                var entityTypePredicate = i >= Constants.DotCount;
                var velMin = MathF.Select(Constants.Dot.MinVelocity, Constants.Bubble.MinVelocity, entityTypePredicate);
                var velMax = MathF.Select(Constants.Dot.MaxVelocity, Constants.Bubble.MaxVelocity, entityTypePredicate);

                Scene.VelocityConstraintComponents[i] = new VelocityConstraintComponent(velMin, velMax);

                var velocity = new VelocityComponent();
                velocity.Value = random.NextVelocity(velMin, velMax);
                Scene.VelocityComponents[i] = velocity;

                var velocityModifierValue = (float)random.NextDouble() * (Constants.Bubble.MaxModifier - Constants.Bubble.MinModifier) + Constants.Bubble.MinModifier;
                var scaleMax     = MathF.Select(Constants.Bubble.MinModifier, Constants.Bubble.MaxModifier, velocityModifierValue >= 0.0f);
                var bubbleAlpha  = (byte)(int)(128 * (velocityModifierValue / scaleMax));
                var bubbleColorR = MathB.Select(0, byte.MaxValue, velocityModifierValue < 0.0f);
                var bubbleColorG = MathB.Select(0, byte.MaxValue, velocityModifierValue >= 0.0f);

                var dotColors = new byte[3];
                random.NextBytes(dotColors);
                var colorR = MathB.Select(dotColors[0], bubbleColorR, entityTypePredicate);
                var colorG = MathB.Select(dotColors[1], bubbleColorG, entityTypePredicate);
                var colorB = MathB.Select(dotColors[2], byte.MinValue, entityTypePredicate);
                var alpha  = MathB.Select(byte.MaxValue, bubbleAlpha, entityTypePredicate);
                var index  = Math.Select(Constants.Sprites.Dot, Constants.Sprites.Bubble, entityTypePredicate);
                Scene.SpriteComponents[i] = new SpriteComponent(colorR, colorG, colorB, alpha, index);

                if (entityTypePredicate)
                {
                    var modifierIndex = i - Constants.DotCount;

                    Scene.SizeComponents[modifierIndex] = new SizeComponent(64);

                    Scene.VelocityModifierComponents[modifierIndex] = new VelocityModifierComponent(velocityModifierValue);
                }
            }

            base.Initialize();
        }
示例#10
0
    void Start()
    {
        EventBus.Subscribe(this);

        moveSystem = GetComponent <MoveSystem>();
    }
 private void Start()
 {
     moveSystem = new MoveSystem(transform, _animator, _speed);
 }
示例#12
0
 private void Awake()
 {
     instance = this;
 }
示例#13
0
    private void Awake()
    {
        PlayerList   = new List <BasicEntity> ();
        EnemyList    = new List <BasicEntity> ();
        basicSystems = new List <BasicSystem> ();

        //找到对应game object动态加载实体

        ////动态加载模块
        //AttackComponent attackComponent = GameObject.Find ("HealthyCube").AddComponent<AttackComponent> ();
        ////必须执行,依次加载组件的初始化,动态加载的组件会在组件管理器中注册
        //attackComponent.Init (ComponentType.Attack, cube);

        ////必须执行,最后初始化实体,它会把直接挂载在game object上的组件一起注册
        //cube.Init ();

        //PlayerList.Add (cube);

        DeadSystem deadSystem = new DeadSystem();

        deadSystem.M_LinkedType = ComponentType.Dead;

        HideSystem hideSystem = new HideSystem();

        hideSystem.M_LinkedType = ComponentType.Hide;

        MoveSystem moveSystem = new MoveSystem();

        moveSystem.M_LinkedType = ComponentType.Move;

        AttackSystem attackSystem = new AttackSystem();

        attackSystem.M_LinkedType = ComponentType.Attack;

        InputSystem inputSystem = new InputSystem();

        inputSystem.M_LinkedType = ComponentType.Input;

        UISystem uiSystem = new UISystem();

        uiSystem.M_LinkedType = ComponentType.UI;

        CheerUpSystem cheerUpSystem = new CheerUpSystem();

        cheerUpSystem.M_LinkedType = ComponentType.CheerUp;

        MonitorSystem monitorSystem = new MonitorSystem();

        monitorSystem.M_LinkedType = ComponentType.Monitor;

        KnockSystem knockSystem = new KnockSystem();

        knockSystem.M_LinkedType = ComponentType.Knock;

        ItemSystem itemSystem = new ItemSystem();

        itemSystem.M_LinkedType = ComponentType.Item;

        AISystem aiSystem = new AISystem();

        aiSystem.M_LinkedType = ComponentType.AI;

        basicSystems.Add(deadSystem);
        basicSystems.Add(hideSystem);
        basicSystems.Add(moveSystem);
        basicSystems.Add(attackSystem);
        basicSystems.Add(inputSystem);
        basicSystems.Add(uiSystem);
        basicSystems.Add(cheerUpSystem);
        basicSystems.Add(monitorSystem);
        basicSystems.Add(knockSystem);
        basicSystems.Add(itemSystem);
        basicSystems.Add(aiSystem);
    }