public static BulletShooter createShooter(chrController chr, SHOT_TYPE type) { BulletShooter bullet_shooter = null; switch (type) { case SHOT_TYPE.EMPTY: { bullet_shooter = chr.gameObject.AddComponent <BulletShooter>(); } break; case SHOT_TYPE.NEGI: { bullet_shooter = chr.gameObject.AddComponent <BulletShooter_negi>(); } break; case SHOT_TYPE.YUZU: { bullet_shooter = chr.gameObject.AddComponent <BulletShooter_yuzu>(); } break; } bullet_shooter.player = chr; return(bullet_shooter); }
public static BulletShooter createShooter(chrController chr, SHOT_TYPE type) { BulletShooter bullet_shooter = null; switch(type) { case SHOT_TYPE.EMPTY: { bullet_shooter = chr.gameObject.AddComponent<BulletShooter>(); } break; case SHOT_TYPE.NEGI: { bullet_shooter = chr.gameObject.AddComponent<BulletShooter_negi>(); } break; case SHOT_TYPE.YUZU: { bullet_shooter = chr.gameObject.AddComponent<BulletShooter_yuzu>(); } break; } bullet_shooter.player = chr; return(bullet_shooter); }
// 네트 플레이어 만들기. public void createNetPlayer(int account_global_index) { chrBehaviorLocal local_player = this.players[0].GetComponent <chrBehaviorLocal>(); chrBehaviorNet net_player = null; int local_index = this.players.Count; AccountData account_data = AccountManager.get().getAccountData(account_global_index); string avator_name = "Player_" + account_data.avator_id; net_player = CharacterRoot.getInstance().createPlayerAsNet(avator_name).GetComponent <chrBehaviorNet>(); net_player.control.local_index = local_index; net_player.control.global_index = account_global_index; net_player.local_player = local_player; net_player.position_in_formation = this.getInFormationOffset(account_global_index); SHOT_TYPE shot_type = GlobalParam.get().shot_type[account_global_index]; net_player.changeBulletShooter(shot_type); net_player.transform.Translate(this.getLocalPlayer().control.getPosition() + net_player.position_in_formation); this.players.Add(net_player); }
/// <summary> /// Changes where the automatic firing will target. /// </summary> /// <param name="target">The target the boulder will be launched at.</param> /// <param name="upwardVel">The initial upward velocity of the boulder.</param> /// <param name="boulderType">The type of boulder being launched. Currently not in use.</param> public void updateTarget(Vector2 target, float upwardVel, SHOT_TYPE boulderType) { defaultTarget = target; defaultUpwardVal = upwardVel; defaultBoulderType = boulderType; switch (defaultBoulderType) { case SHOT_TYPE.STANDARD: projectile = GameManager.Instance.regularShot; break; case SHOT_TYPE.ICE: projectile = GameManager.Instance.iceShot; break; case SHOT_TYPE.FIRE: projectile = GameManager.Instance.fireShot; break; case SHOT_TYPE.BOMB: projectile = GameManager.Instance.bombShot; break; case SHOT_TYPE.SPIKE: projectile = GameManager.Instance.spikeShot; break; default: projectile = GameManager.Instance.regularShot; break; } Debug.Log(defaultUpwardVal); }
public void AddTrebuchet(Vector2 pos, Vector2 target, float upwardForce, SHOT_TYPE shot, bool flip) { this.trebuchetPos.Add(pos); trebuchetTarget.Add(target); upwardVels.Add(upwardForce); boulderType.Add(shot); flipTreb.Add(flip); }
//constructor for the material, this is the base which won't likely be called public Material() { //initiallizes things as unimportant values cost = 0; durability = 10f; forceTransfer = 0.0f; type = MAT_TYPE.NONE; weakness = SHOT_TYPE.NONE; resistance = SHOT_TYPE.NONE; neighbors = new List <Material>(); }
// SHOT_TYPE을 변경한다. public void changeBulletShooter(SHOT_TYPE shot_type) { if (shot_type != this.shot_type) { if (this.bullet_shooter != null) { GameObject.Destroy(this.bullet_shooter); } this.shot_type = shot_type; this.bullet_shooter = BulletShooter.createShooter(this.control, this.shot_type); } }
/// <summary> /// Creates and launches a boulder at a target. /// </summary> /// <param name="target">The target the boulder will be launched at.</param> /// <param name="upwardVel">The initial upward velocity of the boulder.</param> /// <param name="boulderType">The type of boulder being launched. Currently not in use.</param> IEnumerator LaunchBoulder(Vector2 target, float upwardVel, SHOT_TYPE boulderType) { yield return(new WaitForSeconds(0.5f)); projectileHolder = (GameObject)Instantiate(projectile, new Vector3(gameObject.transform.position.x + .5f, gameObject.transform.position.y + .22f, gameObject.transform.position.z - .001f), Quaternion.identity); //Create projectile projectileHolder.transform.parent = drawnObjects.transform; projectileHolder.GetComponent <RockManager>().shot = boulderType; projectileRigidbody = projectileHolder.GetComponent <Rigidbody2D>(); //First, use vertex formula (v = (-initialVel)/(gravity[9.8])) to get time of apex of launch. Then multiply that by 2 for launch time, then apply an x velocity of //(distance between launch point x and target x)/(time of arc). If I'm calculating this correctly, this will even work when objects aren't lined up. float airTime = ((-upwardVel) / (-9.8f)) * 2; float xForce = (target.x - projectileHolder.transform.position.x) / airTime; projectileRigidbody.AddForce(new Vector2(xForce, upwardVel), ForceMode2D.Impulse); Debug.Log("X force: " + xForce); Debug.Log("Upward velocity: " + upwardVel); Debug.Log("Air time: " + airTime); StartCoroutine(DestroyOldProjectiles(false, 5.0f, projectileHolder)); }
// ================================================================ // // 로컬 플레이어 만들기. public void createLocalPlayer(int account_global_index) { if (this.players.Count == 0) { AccountData account_data = AccountManager.get().getAccountData(account_global_index); string avator_name = "Player_" + account_data.avator_id; chrBehaviorLocal local_player = CharacterRoot.getInstance().createPlayerAsLocal(avator_name).GetComponent <chrBehaviorLocal>(); local_player.control.local_index = 0; local_player.control.global_index = account_global_index; local_player.position_in_formation = this.getInFormationOffset(account_global_index); SHOT_TYPE shot_type = GlobalParam.get().shot_type[account_global_index]; local_player.changeBulletShooter(shot_type); this.players.Add(local_player); } }
// 아이템 이름 앞에서 타입을 가져온다. public static SHOT_TYPE getShotType(string name) { SHOT_TYPE shot_type = SHOT_TYPE.NONE; do { char[] delimiterChars = { '_', '.' }; string[] item_name = name.Split(delimiterChars); if (item_name.Length < 3) { break; } if (item_name[0] != "shot") { break; } switch (item_name[1]) { case "negi": { shot_type = SHOT_TYPE.NEGI; } break; case "yuzu": { shot_type = SHOT_TYPE.YUZU; } break; } } while(false); return(shot_type); }
//calculates the damage based on some factor of the shot that hit this block public void CalcDamage(float shotSpeed, SHOT_TYPE damageType) { //as long as force can transfer, deals damage to the neigboring materials if (forceTransfer != 0) { shotSpeed = shotSpeed * forceTransfer; for (int i = 0; i < neighbors.Count; i++) { if (neighbors[i]) { neighbors[i].DoDamage(shotSpeed, damageType); } else { //removes it if it was destroyed recently neighbors.RemoveAt(i); i--; } } } //damages itself last, so it still deals damage to neighbors even if it's destroyed DoDamage(shotSpeed, damageType); }
//deals damage based on a previously calculated amount (either when hit or by transferrence) public void DoDamage(float damage, SHOT_TYPE damageType) { //Play animation to signal damage if (transform.childCount > 1) //Group of Blocks { foreach (Transform child in transform) { Instantiate(GameManager.Instance.dustAnim, child.transform.position + new Vector3(0, 0, -1), Quaternion.identity, GameObject.Find("DrawnObjects").transform); } } else //Single Block { Instantiate(GameManager.Instance.dustAnim, transform.position + new Vector3(0, 0, -1), Quaternion.identity, GameObject.Find("DrawnObjects").transform); } if (audioManager != null) //Plays hit noise { audioManager.playBlockHitClip(); } if (damageType == this.weakness) { //double damage if it is weak to this attack this.durability -= (damage * 2); } else if (damageType == this.resistance) { //halves if it resists it this.durability -= (damage / 2); } else { //regular damage otherwise this.durability -= damage; } Debug.Log(damage); if (this.durability <= 0.0f) { //destroy the object this is attatched to. Destroy(gameObject); if (audioManager != null) //Plays destroyed noise { audioManager.playBlockBreak2Clip(); } } else { if (audioManager != null) //Plays hit noise { audioManager.playBlockHitClip(); } float percentage = durability / durabilityMax; //sets the color to red, but with tinted using a percentage of health if (gameObject.name == "block group") { //does it for all children foreach (Transform childTransform in transform) { childTransform.GetComponent <SpriteRenderer>().color = new Color(1f, percentage, percentage); } } else { //sets the color of the tint child gameObject.GetComponent <SpriteRenderer>().color = new Color(1f, percentage, percentage); } } }
// SHOT_TYPE을 변경한다. public void changeBulletShooter(SHOT_TYPE shot_type) { if(shot_type != this.shot_type) { if(this.bullet_shooter != null) { GameObject.Destroy(this.bullet_shooter); } this.shot_type = shot_type; this.bullet_shooter = BulletShooter.createShooter(this.control, this.shot_type); } }
private void resolve_pick_item_query(QueryItemPick query) { do { if (!query.isSuccess()) { break; } // 아이템 효과만 복사하고 삭제한다. ItemController item = this.control.cmdItemPick(query, query.target); if (item == null) { break; } // 이펙트. EffectRoot.get().createItemGetEffect(this.control.getPosition()); SoundManager.get().playSE(Sound.ID.DDG_SE_SYS02); Debug.Log("Item favor category:" + item.behavior.item_favor.category); switch (item.behavior.item_favor.category) { case Item.CATEGORY.FOOD: { this.control.vital.healFull(); this.skin_color_control.startHealing(); this.cake_count++; } break; case Item.CATEGORY.KEY: { PartyControl.get().getLocalPlayer().control.consumeKey(item); } break; case Item.CATEGORY.FLOOR_KEY: { PartyControl.get().getLocalPlayer().control.consumeKey(item); } break; case Item.CATEGORY.CANDY: { this.startShotBoost(); } break; case Item.CATEGORY.WEAPON: { SHOT_TYPE shot_type = Item.Weapon.getShotType(item.name); if (shot_type != SHOT_TYPE.NONE) { this.changeBulletShooter(shot_type); } } break; } item.vanish(); } while(false); query.set_expired(true); }
private void resolve_pick_item_query(QueryItemPick query) { do { if (!query.isSuccess()) { break; } // ?꾩씠???⑤뒫留?蹂듭궗?섍퀬 ??젣?쒕떎. ItemController item = this.control.cmdItemPick(query, query.target); if (item == null) { break; } // ?④낵. EffectRoot.get().createItemGetEffect(this.control.getPosition()); SoundManager.get().playSE(Sound.ID.DDG_SE_SYS02); switch (item.behavior.item_favor.category) { case Item.CATEGORY.CANDY: { // ?꾩씠??李쎌뿉 ?꾩씠肄??쒖떆. this.item_slot.candy.favor = item.behavior.item_favor.clone(); ItemWindow.get().setItem(Item.SLOT_TYPE.CANDY, 0, this.item_slot.candy.favor); // ?룹쓽 ?쇱젙?쒓컙 ?뚯썙?? this.startShotBoost(); } break; case Item.CATEGORY.SODA_ICE: case Item.CATEGORY.ETC: { // 鍮??щ’???꾩씠???ㅼ젙. int slot_index = this.item_slot.getEmptyMiscSlot(); if (slot_index >= 0) { this.item_slot.miscs[slot_index].item_id = query.target; this.item_slot.miscs[slot_index].favor = item.behavior.item_favor.clone(); // ?꾩씠??李쎌뿉 ?꾩씠肄??쒖떆. ItemWindow.get().setItem(Item.SLOT_TYPE.MISC, slot_index, this.item_slot.miscs[slot_index].favor); } } break; case Item.CATEGORY.FOOD: { // 泥대젰 ?뚮났. if (GameRoot.get().isNowCakeBiking()) { this.control.vital.healFullInternal(); } else { this.control.vital.healFull(); // ?덉씤蹂댁슦 移쇰윭 ?④낵. this.skin_color_control.startHealing(); } // 泥대젰 ?뚮났???뚮┝. CharacterRoot.get().NotifyHitPoint(this.getAcountID(), this.control.vital.getHitPoint()); // ?꾩씠???먭린瑜??뚮┝. this.control.cmdItemDrop(query.target); // 耳?댄겕瑜?癒뱀? ??耳?댄겕 臾댄븳?쒓났??. this.cake_count++; } break; // 諛??댁뇿. case Item.CATEGORY.KEY: { PartyControl.get().getLocalPlayer().control.consumeKey(item); Item.KEY_COLOR key_color = Item.Key.getColorFromInstanceName(item.name); // ?꾩씠??李쎌뿉 ?꾩씠肄??쒖떆. if (key_color != Item.KEY_COLOR.NONE) { ItemWindow.get().setItem(Item.SLOT_TYPE.KEY, (int)key_color, item.behavior.item_favor); } } break; // ?뚮줈???대룞 臾??댁뇿. case Item.CATEGORY.FLOOR_KEY: { MapCreator.getInstance().UnlockBossDoor(); // ?꾩씠??李쎌뿉 ?꾩씠肄??쒖떆. ItemWindow.get().setItem(Item.SLOT_TYPE.FLOOR_KEY, 0, item.behavior.item_favor); } break; case Item.CATEGORY.WEAPON: { // ??蹂寃????諛쒖뭏 / ?좎옄 ??깂). SHOT_TYPE shot_type = Item.Weapon.getShotType(item.name); if (shot_type != SHOT_TYPE.NONE) { this.changeBulletShooter(shot_type); } } break; } item.vanish(); } while(false); query.set_expired(true); }
// ================================================================ // // 肄쒕━?꾩쓽 ?섎? 遺?? protected void resolve_collision() { foreach (var result in this.control.collision_results) { if (result.object1 == null) { continue; } //GameObject self = result.object0; GameObject other = result.object1; // ?뚮젅?댁뼱媛 蹂댁뒪??肄쒕━?꾩뿉 ?뚮춱? ?吏곸씪 ???녾쾶 ?섏? ?딄쾶. // 諛⑹쓽 以묒떖 諛⑺뼢?쇰줈 諛?대궦?? if (other.tag == "Boss") { if (this.force_push_out(result)) { continue; } } switch (other.tag) { case "Enemy": case "EnemyLair": case "Boss": { do { chrBehaviorEnemy enemy = other.GetComponent <chrBehaviorEnemy>(); if (enemy == null) { break; } if (!this.melee_attack.isInAttackRange(enemy.control)) { //break; } if (this.step.get_current() == STEP.MELEE_ATTACK) { break; } if (!this.melee_attack.isHasInput()) { break; } this.melee_target = enemy; this.step.set_next(STEP.MELEE_ATTACK); } while(false); result.object1 = null; } break; case "Door": { this.cmdNotiryStayDoorBox(other.gameObject.GetComponent <DoorControl>()); } break; case "Item": { do { ItemController item = other.GetComponent <ItemController>(); // ?꾩씠?쒖쓣 二쇱슱?섏엳??議곗궗?쒕떎. bool is_pickable = true; switch (item.behavior.item_favor.category) { case Item.CATEGORY.CANDY: { is_pickable = this.item_slot.candy.isVacant(); } break; case Item.CATEGORY.SODA_ICE: case Item.CATEGORY.ETC: { int slot_index = this.item_slot.getEmptyMiscSlot(); // ?щ’??媛??= ??媛吏????놁쓣 ?? if (slot_index < 0) { is_pickable = false; } } break; case Item.CATEGORY.WEAPON: { // ?ъ슜 以묒씤 ?룰낵 媛숈쑝硫?二쇱슱 ???녿떎. SHOT_TYPE shot_type = Item.Weapon.getShotType(item.name); is_pickable = (this.shot_type != shot_type); } break; } if (!is_pickable) { break; } this.control.cmdItemQueryPick(item.name, true, false); } while(false); } break; } } }
private void resolve_pick_item_query(QueryItemPick query) { do { if (!query.isSuccess()) { break; } // 아이템 효능만 복사하고 삭제한다. ItemController item = this.control.cmdItemPick(query, query.target); if (item == null) { break; } // 효과. EffectRoot.get().createItemGetEffect(this.control.getPosition()); SoundManager.get().playSE(Sound.ID.DDG_SE_SYS02); switch (item.behavior.item_favor.category) { case Item.CATEGORY.CANDY: { // 아이템 창에 아이콘 표시. this.item_slot.candy.favor = item.behavior.item_favor.clone(); ItemWindow.get().setItem(Item.SLOT_TYPE.CANDY, 0, this.item_slot.candy.favor); // 샷의 일정시간 파워업 this.startShotBoost(); } break; case Item.CATEGORY.SODA_ICE: case Item.CATEGORY.ETC: { // 빈 슬롯에 아이템 설정. int slot_index = this.item_slot.getEmptyMiscSlot(); if (slot_index >= 0) { this.item_slot.miscs[slot_index].item_id = query.target; this.item_slot.miscs[slot_index].favor = item.behavior.item_favor.clone(); // 아이템 창에 아이콘 표시. ItemWindow.get().setItem(Item.SLOT_TYPE.MISC, slot_index, this.item_slot.miscs[slot_index].favor); } } break; case Item.CATEGORY.FOOD: { // 체력 회복. if (GameRoot.get().isNowCakeBiking()) { this.control.vital.healFullInternal(); } else { this.control.vital.healFull(); // 레인보우 칼러 효과. this.skin_color_control.startHealing(); } // 체력 회복을 알림. CharacterRoot.get().NotifyHitPoint(this.getAcountID(), this.control.vital.getHitPoint()); // 아이템 폐기를 알림. this.control.cmdItemDrop(query.target); // 케이크를 먹은 수(케이크 무한제공용). this.cake_count++; } break; // 방 열쇠. case Item.CATEGORY.KEY: { PartyControl.get().getLocalPlayer().control.consumeKey(item); Item.KEY_COLOR key_color = Item.Key.getColorFromInstanceName(item.name); // 아이템 창에 아이콘 표시. if (key_color != Item.KEY_COLOR.NONE) { ItemWindow.get().setItem(Item.SLOT_TYPE.KEY, (int)key_color, item.behavior.item_favor); } } break; // 플로어 이동 문 열쇠. case Item.CATEGORY.FLOOR_KEY: { MapCreator.getInstance().UnlockBossDoor(); // 아이템 창에 아이콘 표시. ItemWindow.get().setItem(Item.SLOT_TYPE.FLOOR_KEY, 0, item.behavior.item_favor); } break; case Item.CATEGORY.WEAPON: { // 샷 변경(대파 발칸 / 유자 폭탄). SHOT_TYPE shot_type = Item.Weapon.getShotType(item.name); if (shot_type != SHOT_TYPE.NONE) { this.changeBulletShooter(shot_type); } } break; } item.vanish(); } while(false); query.set_expired(true); }
// ================================================================ // // 디버그 창을 만든다(플레이어 관련). protected void create_debug_window_player() { var window = dbwin.root().createWindow("player"); window.createButton("당했다") .setOnPress(() => { var player = PartyControl.getInstance().getLocalPlayer(); player.control.causeDamage(100.0f, -1); }); window.createButton("아이스 과식") .setOnPress(() => { var player = PartyControl.getInstance().getLocalPlayer(); if (!player.isNowJinJin()) { player.startJinJin(); } else { player.stopJinJin(); } }); window.createButton("크림 범벅 테스트") .setOnPress(() => { var player = PartyControl.getInstance().getLocalPlayer(); if (!player.isNowCreamy()) { player.startCreamy(); } else { player.stopCreamy(); } }); window.createButton("체력 회복 테스트") .setOnPress(() => { var player = PartyControl.getInstance().getLocalPlayer(); if (!player.isNowHealing()) { player.startHealing(); } else { player.stopHealing(); } }); window.createButton("아이스 당첨 테스트") .setOnPress(() => { window.close(); EventRoot.get().startEvent <EventIceAtari>(); }); window.createButton("무기 교체") .setOnPress(() => { var player = PartyControl.getInstance().getLocalPlayer(); SHOT_TYPE shot_type = player.getShotType(); shot_type = (SHOT_TYPE)(((int)shot_type + 1) % ((int)SHOT_TYPE.NUM)); player.changeBulletShooter(shot_type); }); }
// ================================================================ // // 콜리전의 의미 부여. protected void resolve_collision() { foreach (var result in this.control.collision_results) { if (result.object1 == null) { continue; } //GameObject self = result.object0; GameObject other = result.object1; // 플레이어가 보스의 콜리전에 파뭍혀 움직일 수 없게 되지 않게. // 방의 중심 방향으로 밀어낸다. if (other.tag == "Boss") { if (this.force_push_out(result)) { continue; } } switch (other.tag) { case "Enemy": case "EnemyLair": case "Boss": { do { chrBehaviorEnemy enemy = other.GetComponent <chrBehaviorEnemy>(); if (enemy == null) { break; } if (!this.melee_attack.isInAttackRange(enemy.control)) { //break; } if (this.step.get_current() == STEP.MELEE_ATTACK) { break; } if (!this.melee_attack.isHasInput()) { break; } this.melee_target = enemy; this.step.set_next(STEP.MELEE_ATTACK); } while(false); result.object1 = null; } break; case "Door": { this.cmdNotiryStayDoorBox(other.gameObject.GetComponent <DoorControl>()); } break; case "Item": { do { ItemController item = other.GetComponent <ItemController>(); // 아이템을 주울수있나 조사한다. bool is_pickable = true; switch (item.behavior.item_favor.category) { case Item.CATEGORY.CANDY: { is_pickable = this.item_slot.candy.isVacant(); } break; case Item.CATEGORY.SODA_ICE: case Item.CATEGORY.ETC: { int slot_index = this.item_slot.getEmptyMiscSlot(); // 슬롯이 가득 = 더 가질 수 없을 때. if (slot_index < 0) { is_pickable = false; } } break; case Item.CATEGORY.WEAPON: { // 사용 중인 샷과 같으면 주울 수 없다. SHOT_TYPE shot_type = Item.Weapon.getShotType(item.name); is_pickable = (this.shot_type != shot_type); } break; } if (!is_pickable) { break; } this.control.cmdItemQueryPick(item.name, true, false); } while(false); } break; } } }