예제 #1
0
            public void Execute(int index)
            {
                HealthDamageCooldown hcd = HurtCooldown[index];

                if (hcd.Value > 0.0f)
                {
                    hcd.Value          -= dt;
                    HurtCooldown[index] = hcd;
                }
            }
예제 #2
0
            public void Execute(int index)
            {
                // dmg from enemies to player
                float3               playerPos    = PlayerPos[index].Value;
                Health               playerHealth = PlayerHealth[index];
                BlinkTimer           playerBlink  = Blinks[index];
                HealthDamageCooldown hcd          = HurtCooldown[index];

                for (int i = 0; i < EnemyPos.Length; ++i)
                {
                    float3 enemyPos = EnemyPos[i].Value;
                    float3 distance = enemyPos - playerPos;
                    float  squard   = math.dot(distance, distance);
                    // player been touched
                    if (squard <= PlayerHitboxRadiusSquared && hcd.CanBeHurt)
                    {
                        playerHealth.Value  = math.max(playerHealth.Value - GameSettings.ENEMY_DMG, 0);
                        hcd.Value           = GameSettings.HURT_COOLDOWN;
                        PlayerHealth[index] = playerHealth;
                        HurtCooldown[index] = hcd;
                        playerBlink.Value   = GameSettings.BLINK_TIME * 5;
                        Blinks[index]       = playerBlink;
                    }

/*                  Health enemy_health = EnemyHealth[i];
 *                                      for(int j=0;j<Shots.Length;++j)
 *                                      {
 *                                              // dmg from player shots to enemies
 *                                              float3 shotPos = ShotPos[j].Value;
 *                                              float3 delta = shotPos - enemyPos;
 *                                              float squard_to_bullet = math.dot(delta,delta);
 *                                              Shot s = Shots[j];
 *                                              if(squard_to_bullet <= EnemyHitboxRadiusSquared)
 *                                              {
 *                                                      // destroy bullet
 *                                                      s.TimeToLive = 0.0f;
 *                                                      // -hp
 *                                                      enemy_health.Value -= GameSettings.BULLET_DMG;
 *                                                      Shots[j] = s;
 *                                                      EnemyHealth[i] = enemy_health;
 *                                                      break;
 *                                              }
 *                                      } */
                }
            }