public virtual void killPlayer(PlayerEntity player) { /************************抢夺积分************************************/ int temp = Math.Min(Mathf.RoundToInt(player.fightResult.score * ConfigConstant.SCORE_KILL_PLAYER_RATE), ConfigConstant.SCORE_KILL_PLAYER_MAX); player.changeScore(-temp); this.changeScore(temp + ConfigConstant.SCORE_KILL_PLAYER); /************************生成豆************************************/ double angle = this._map.getRandomRange(0, Math2.PI2); for (int i = 0; i < ConfigConstant.DEAD_ITEM_NUM; i++) { PriceBeanEntity entity = this.map.createFightEntity(ConfigConstant.ENTITY_PRICE_BEAN) as PriceBeanEntity; int index = i % 2 + 1; entity.id = "bean" + index; entity.position.copy(player.position); Dictionary <string, object> config = (Dictionary <string, object>)ConfigConstant.powerConfig[entity.id]; entity.initConfig(config); entity.addForce(Vector2D.createVector2(ConfigConstant.DEAD_ITEM_FORCE, Math2.PI2 * i / ConfigConstant.DEAD_ITEM_NUM + angle)); } int len = Mathf.RoundToInt(player.fightResult.score * ConfigConstant.DROP_SCORE_ITEM_RATE / ConfigConstant.SCORE_UNIT) + ConfigConstant.DROP_SCORE_ITEM_MIN; len = Math.Min(len, ConfigConstant.DROP_SCORE_ITEM_MAX); this.changeScore(-len * ConfigConstant.SCORE_UNIT); angle = this._map.getRandomRange(0, Math2.PI2); for (int i = 0; i < len; i++) { double force = this._map.getRandomRange(ConfigConstant.DROP_SCORE_ITEM_FORCE_MIN, ConfigConstant.DROP_SCORE_ITEM_FORCE_MAX); PriceBeanEntity entity = this.map.createFightEntity(ConfigConstant.ENTITY_PRICE_BEAN) as PriceBeanEntity; entity.id = "bean" + 4; entity.position.copy(player.position); Dictionary <string, object> config = (Dictionary <string, object>)ConfigConstant.powerConfig[entity.id]; entity.initConfig(config); entity.addForce(Vector2D.createVector2(force, Math2.PI2 * i / len + angle)); } /************************杀敌记录************************************/ this.fightResult.killPerson(); this._map.killPlayerNum++; //萝卜模式要扔掉萝卜。 if (this._map.mapData.isRadish) { if (this._map.refereeController.checkDropRadish(player)) { this.fightResult.recordShot++; player.fightResult.recordBeShot++; } } }
public override FightEntity createFightEntity(int type, int netId = -1) { FightEntity entity = null; switch (type) { case ConfigConstant.ENTITY_LOOP_BEAN: // entity = new LoopBeanEntity(this); break; case ConfigConstant.ENTITY_PLAYER: entity = new PlayerEntity(this); break; case ConfigConstant.ENTITY_BULLET: entity = new BulletEntity(this); break; case ConfigConstant.ENTITY_PRICE_BEAN: entity = new PriceBeanEntity(this); break; case ConfigConstant.ENTITY_CALL: entity = new CallEntity(this); break; case ConfigConstant.ENTITY_BARRIER: entity = new BarrierEntity(this); break; case ConfigConstant.ENTITY_RADISH: entity = new RadishEntity(this); break; } return(entity); }