public static BatEnemyRepresentation CreateBatRepresentation(BatEnemy enemy, EnemyEvent enemyEvent, ContentManager content) { BatEnemyRepresentation enemyRepresentation = new BatEnemyRepresentation(enemy, enemyEvent); enemyRepresentation.LoadContent(content); return enemyRepresentation; }
public static BatEnemy CreateBatEntity(World world, EnemyEvent enemyEvent, Vector2 enemyPosition) { ConfigFile configFile = Enemy.GetEnemyConfigFile(); int health = configFile.SettingGroups[batGeneralSettings].Settings["health"].GetValueAsInt(); float hitDelay = configFile.SettingGroups[batGeneralSettings].Settings["hitDelay"].GetValueAsFloat(); float recoveryDelay = configFile.SettingGroups[batGeneralSettings].Settings["recoveryDelay"].GetValueAsFloat(); BatEnemy enemy = new BatEnemy(world, enemyEvent); enemy.SetUpEnemy(enemyPosition, health, hitDelay, recoveryDelay); return enemy; }
public static BatEnemyController CreateBatController(BatEnemy enemy) { BatEnemyController enemyController = new BatEnemyController(enemy); return enemyController; }
// Update is called once per frame void Update() { anim.Draw(this.transform.position); if (col) { TwoColCircle colPhys = col; TwoColCircle colOff = col; List <TwoColManager.Col> other = colPhys.ColManager.CheckCol(colPhys); if (other.Count > 0) { foreach (TwoColManager.Col e in other) { transform.position += (Vector3)e.move; } } List <TwoColManager.Col> other2 = colOff.ColManager.CheckCol(colOff); if (other2.Count > 0) { foreach (TwoColManager.Col e in other2) { BatMoth colMoth = e.col.GetComponent <BatMoth>(); BatEnemy colEnemy = e.col.GetComponent <BatEnemy>(); if (colMoth) { } else if (colEnemy) { transform.position = new Vector3(100.0f, 150.0f, 0.0f); } } } } if (Input.GetKey("left")) { xSpeed -= xSpeedAccel - xSpeedAccel * xSpeedAccelChange * weight; } else if (Input.GetKey("right")) { xSpeed += xSpeedAccel - xSpeedAccel * xSpeedAccelChange * weight; } else { if (Mathf.Abs(xSpeed) > 0.05f) { xSpeed *= xFriction + (1.0f - xFriction) * xFrictionChange * weight; } else { xSpeed = 0.0f; } } if (xSpeed > xSpeedMax || xSpeed < -xSpeedMax) { xSpeed *= 0.95f; } if (ySpeed > -ySpeedMax) { ySpeed -= gravity; } if (energy > 0.0f && Input.GetKeyDown("up")) { ySpeed += flapHeight; if (Input.GetKey("right")) { xSpeed -= xSpeedAccel - xSpeedAccel * xSpeedAccelChange * weight * 50.0f; } else if (Input.GetKey("left")) { xSpeed += xSpeedAccel - xSpeedAccel * xSpeedAccelChange * weight * 50.0f; } energy -= 0.05f; if (energy < 0.0f) { energy = 0.0f; } weight -= 0.025f; if (weight < 0.0f) { weight = 0.0f; } energyBar.SetValue(energy); weightBar.SetValue(weight); anim.PlayOnce(0, 4, 0.04f); } if (Input.GetKey("up")) { if (ySpeed < -ySpeedGlide) { ySpeed = -ySpeedGlide; //(ySpeed + ySpeedGlide)*0.5f; } } if (Time.frameCount % 50 == 0) { weight -= 0.01f; weightBar.SetValue(weight); } ySpeed = Mathf.Clamp(ySpeed, -ySpeedMax, ySpeedMax); transform.position += new Vector3(xSpeed, ySpeed, 0.0f); }