示例#1
0
    public override void Update()
    {
        //HasSpeedUpComponent speedUp;
        constraint.ForEachGameObject((egoComponent, transform, powerUpComponent, movementComponent) => {
            if (powerUpComponent.powerUpActivated)
            {
                movementComponent.flySpeed  = 4;
                movementComponent.curvspeed = 2.9f;
                Ego.DestroyComponent <HasSpeedUpComponent>(egoComponent);
            }

            if (powerUpComponent.powerUpActivated)
            {
                powerUpComponent.playerPowerUpTimer += Time.deltaTime;
            }
            if (powerUpComponent.playerPowerUpTimer >= 2)
            {
                powerUpComponent.playerPowerUpTimer = -1f;
                movementComponent.flySpeed          = 2;
                movementComponent.curvspeed         = 2;
                powerUpComponent.powerUpActivated   = false;
            }

            HasSpeedUpComponent speed;
            if ((KutiInput.Instance.GetButtonDown(powerUpComponent.powerUpButton) || Input.GetKey(powerUpComponent.powerUpButtonPC) && egoComponent.TryGetComponents(out speed)))
            {
                var ev = new OnActivatePowerUp(powerUpComponent.playerID, egoComponent);
                EgoEvents <OnActivatePowerUp> .AddEvent(ev);
            }
        });
    }
示例#2
0
 void Handle(TickEvent e)
 {
     constraint.ForEachGameObject((egoComponent, delayer, collider) =>
     {
         if (delayer.ready)
         {
             collider.enabled = true;
             Ego.DestroyComponent <DelayColliderComponent>(egoComponent);
         }
         else
         {
             delayer.ready = true;
         }
     });
 }
示例#3
0
 void Handle(CollisionEnter2DEvent e)
 {
     constraint.ForEachGameObject((egoComponent, transform, rigbody, jump, player, onCollissionEnter, Animator, AnimationComponent, spriteRend, serialPort) => {
         //When Player lands on ground
         if (e.egoComponent2.HasComponents <Ground>() && jump.jumpstatus == JumpComponent.Jumpstatus.falling)
         {
             jump.jumpstatus = JumpComponent.Jumpstatus.grounded;
             Ego.DestroyComponent <JumpStatus>(egoComponent);
         }
         //When Player jumps against a plattform
         if (e.egoComponent2.HasComponents <Ground>() && jump.jumpstatus == JumpComponent.Jumpstatus.jumping)
         {
             jump.jumpPosition.y = egoComponent.transform.position.y - jump.jumpHeight;
         }
         //When Player lands on Player
         if (e.egoComponent2.HasComponents <PlayerComponent> () && e.egoComponent1.HasComponents <JumpComponent>())
         {
             if (e.egoComponent1.GetComponent <JumpComponent>().jumpstatus == JumpComponent.Jumpstatus.falling)
             {
                 e.egoComponent1.GetComponent <PlayerComponent>().score++;
                 if (e.egoComponent1.GetComponent <PlayerComponent>().score == 12)
                 {
                     EgoEvents <GameEndEvent> .AddEvent(new GameEndEvent(e.egoComponent1.GetComponent <PlayerComponent>().playerID));
                 }
                 EgoEvents <ScoreEvent> .AddEvent(new ScoreEvent(e.egoComponent1.GetComponent <PlayerComponent>().playerID, e.egoComponent1.GetComponent <PlayerComponent>().score));
                 EgoEvents <PlayerHitEvent> .AddEvent(new PlayerHitEvent());
             }
         }
         if (e.egoComponent1.HasComponents <PlayerComponent> () && e.egoComponent2.HasComponents <JumpComponent>())
         {
             if (e.egoComponent2.GetComponent <JumpComponent>().jumpstatus == JumpComponent.Jumpstatus.falling)
             {
                 e.egoComponent2.GetComponent <PlayerComponent>().score++;
                 if (e.egoComponent2.GetComponent <PlayerComponent>().score == 12)
                 {
                     EgoEvents <GameEndEvent> .AddEvent(new GameEndEvent(e.egoComponent2.GetComponent <PlayerComponent>().playerID));
                 }
                 EgoEvents <ScoreEvent> .AddEvent(new ScoreEvent(e.egoComponent2.GetComponent <PlayerComponent>().playerID, e.egoComponent2.GetComponent <PlayerComponent>().score));
                 EgoEvents <PlayerHitEvent> .AddEvent(new PlayerHitEvent());
             }
         }
     });
 }