public void ServerModify(ProjectileKind kind, int amount) { if (isServer) { RpcModify(kind, amount); } }
public GameObject getProjectileModel(ProjectileKind shotToShow) { GameObject prefab = PrefabRegistry.singleton.GetPrefab <ProjectileKind>(shotToShow); GameObject shotModelPrefab = prefab.transform.Find("Model").gameObject; GameObject shotModel = (GameObject)GameObject.Instantiate(shotModelPrefab, projectileModelWorldPosition.position, projectileModelWorldPosition.rotation); shotModel.transform.parent = projectileModelWorldPosition; SetLayer(shotModel.transform, projectileModelWorldPosition.gameObject.layer); Vector3 scale = shotModel.transform.localScale; scale.x *= prefab.transform.localScale.x; scale.y *= prefab.transform.localScale.y; scale.z *= prefab.transform.localScale.z; scale.x *= projectileModelWorldPosition.localScale.x; scale.y *= projectileModelWorldPosition.localScale.y; scale.z *= projectileModelWorldPosition.localScale.z; shotModel.transform.localScale = scale; if (shotToShow == ProjectileKind.mushboom) { shotModel.transform.Rotate(Vector3.up); } else { shotModel.transform.localRotation = shotModelPrefab.transform.localRotation; } return(shotModel); }
public void AssignLoot( ProjectileKind kind, int count ) { this.lootKind = kind; this.lootCount = count; }
public void SetSelected(ProjectileKind selectedShot) { lastSelectedShot = selectedShot; foreach (var projectileKind in ammoRegistry.Keys) { ammoRegistry[projectileKind].SetIsActive(selectedShot == projectileKind); } }
public void Init(WeaponInfo weapon, ProjectileKind kind, Vector3 position, Vector3 direction) { this.info.weapon = weapon; this.info.instance = this; this.info.kind = kind; transform.position = position; transform.rotation = Quaternion.LookRotation(direction); Go(); }
void Awake() { selectedProjectile = ProjectileKind.cannonBall; projetileModels = new Dictionary <ProjectileKind, GameObject>(); projetileModels[selectedProjectile] = getProjectileModel(selectedProjectile); UpdateSelectedShot(); forceAmmoUpdate = true; adjustProjectileModelPosition(); }
public static string ForProjectile(ProjectileKind projectileKind) { if (projectileMapping.ContainsKey(projectileKind)) { return(projectileMapping[projectileKind]); } else { return(projectileKind.ToString()); } }
// highlight A54202FF // normal 6B4E29FF public void AssignAmmo(ProjectileKind projectileKind, int count) { ammoNameText.text = NameMapping.ForProjectile(projectileKind); if (count > 99) { ammoCountText.text = "99+"; } else { ammoCountText.text = count.ToString(); } }
void OnHit(ProjectileKind kind, Vector3 point) { if (!this.clipsDictionary.TryGetValue(kind, out var clips)) { Debug.LogError($"{typeof(ProjectileAudioFXController).Name}: don't contain \"{kind}\" kind!", gameObject); return; } if (clips.hit != null) { var sound = factory.GetObject(); sound.PlayOneShoot(point, clips.hit, 100); } }
public ProjectileEffectEventArgs(string effectName, string iD, string taleSpireId, float speed, int count, ProjectileKind kind, FireCollisionEventOn fireCollisionEventOn, float launchTimeVariance, float targetVariance, Target target, ProjectileSizeOption projectileSize, float projectileSizeMultiplier, float bezierPathMultiplier) : base(effectName, iD, taleSpireId) { BezierPathMultiplier = bezierPathMultiplier; ProjectileSizeMultiplier = projectileSizeMultiplier; ProjectileSize = projectileSize; Target = target; Speed = speed; Count = count; Kind = kind; FireCollisionEventOn = fireCollisionEventOn; LaunchTimeVariance = launchTimeVariance; TargetVariance = targetVariance; }
void OnHit(ProjectileKind kind, PointInfo point) { if (!this.dict.TryGetValue(kind, out var info)) { return; } Debug.LogWarning($"IMPACT EFFECT! kind: {kind}, point: {point.point}"); var effect = factory.GetObject(info.impact); effect.TR.position = point.point; effect.TR.rotation = Quaternion.LookRotation(point.normal); }
#pragma warning restore 649 public Projectile GetObject(ProjectileKind info) { if (!this.projectilePoolKeyDict.TryGetValue(info, out var key)) { MyLogger.ObjectErrorFormat <ProjectilePooledFactory>("don't contain \"{0}\" kind!", info); return(null); } if (!ObjectPool.I.TrySpawn(key, out var obj)) { MyLogger.ObjectErrorFormat <ProjectilePooledFactory>("\"{0}\" kan't be spawned!", key); return(null); } return(obj.GetComponent <Projectile>()); }
public void RegisterAlienProjectile(Projectile proj, ProjectileKind kind, WeaponInfo wInfo, Vector3 pos, Vector3 dir) { //if (!NetworkServer.active) return; if (proj == null) { return; } //NetworkServer.Spawn(proj.gameObject); Subscribe(proj); proj.Init(wInfo, kind, pos, dir); OnShoot(proj.Info, new PointInfo { point = pos, direction = dir, normal = dir }); }
void CmdFire(float shotPower, ProjectileKind projectiledKind) { //Debug.Log("CmdFire for " + name + " hasControl: " + hasControl); // controller state-based authorization check if (!hasControl) { // Debug.Log("nope"); return; } // instantiate from prefab var prefab = PrefabRegistry.singleton.GetPrefab <ProjectileKind>(projectiledKind); var liveProjectile = (GameObject)GameObject.Instantiate( prefab, model.shotSource.position, model.shotSource.rotation ); ProjectileController liveProjectileController = liveProjectile.GetComponent <ProjectileController>(); if (isSlowed) { liveProjectile.GetComponent <Rigidbody>().mass *= 2; liveProjectileController.molasses.Play(); liveProjectileController.isSlowed = true; isSlowed = false; slowParticles.Stop(); } else { Destroy(liveProjectileController.molasses); } liveProjectile.name = name + "Projectile"; liveProjectile.layer = gameObject.layer; liveProjectileController.shooter = this; liveProjectileController.SetProjectileKind(selectedShot); // set initial velocity/force liveProjectile.GetComponent <Rigidbody>().AddForce(model.shotSource.forward * shotPower); // set network spawn NetworkServer.Spawn(liveProjectile); // update manager if (TurnManager.singleton != null) { TurnManager.singleton.ServerHandleShotFired(this, liveProjectile); } }
#pragma warning restore 649 public Projectile GetObject(ProjectileKind info) { var projs = m_Projectiles; int count = projs.Length; for (int i = 0; i < count; ++i) { if (projs[i].Info.kind == info) { return(Instantiate(projs[i])); } } return(null); }
ProjectileKind FindAvailableShot(ProjectileKind currentShot, int modifier) { var nextShot = (maxShot + (int)currentShot + modifier) % maxShot; while (nextShot != (int)currentShot) { if (ammoCounts[nextShot] > 0) { return((ProjectileKind)nextShot); } nextShot = (maxShot + nextShot + modifier) % maxShot; } return(currentShot); }
public void Modify(ProjectileKind kind, int amount) { if (ammoCounts[(int)kind] != int.MaxValue) { if (amount == int.MaxValue) { ammoCounts[(int)kind] = amount; } else { ammoCounts[(int)kind] += amount; } } onModifyEvent.Invoke(this); }
void UpdateSelectedShot() { if (forceAmmoUpdate || (activeTank != null && selectedProjectile != activeTank.selectedShot)) { forceAmmoUpdate = false; projetileModels[selectedProjectile].SetActive(false); if (!projetileModels.ContainsKey(activeTank.selectedShot)) { projetileModels[activeTank.selectedShot] = getProjectileModel(activeTank.selectedShot); } projetileModels[activeTank.selectedShot].SetActive(true); selectedProjectile = activeTank.selectedShot; // update ammo list panel to reference selected projectile ammoListPanel.SetSelected(selectedProjectile); } }
void Awake() { ammoRegistry = new Dictionary <ProjectileKind, AmmoInfoController>(); lastSelectedShot = ProjectileKind.cannonBall; }
/// <summary> /// This is the state-engine driving the aim/power/shot control for the tank. /// Stay in this state until a shot is fired. /// NOTE: ensure that all yield calls are using next of frame (yield return null) to ensure proper input handling /// </summary> IEnumerator AimStateEngine() { // check to see if we still have availability for selected shot if (shotInventory.GetAvailable(selectedShot) <= 0) { selectedShot = shotInventory.NextAvailableShot(selectedShot); Debug.Log("now using shot: " + selectedShot); } // Debug.Log("AimStateEngine called for " + this.name + " with isServer: " + isServer + " and hasControl: " + hasControl); // continue while we have control while (hasControl) { if (EventSystem.current.currentSelectedGameObject != null && EventSystem.current.currentSelectedGameObject.tag == "inputexclusive") { yield return(null); continue; } // FlyCam Controls if (FlyCam.self.isEnabled) { if (Input.GetKeyDown(KeyCode.KeypadPlus)) { FlyCam.self.ZoomIn(); } else if (Input.GetKeyDown(KeyCode.KeypadMinus)) { FlyCam.self.ZoomOut(); } if (Input.GetKey(KeyCode.I)) { FlyCam.self.MoveForward(); } else if (Input.GetKey(KeyCode.K)) { FlyCam.self.MoveBack(); } if (Input.GetKey(KeyCode.J)) { FlyCam.self.MoveLeft(); } else if (Input.GetKey(KeyCode.L)) { FlyCam.self.MoveRight(); } if (Input.GetKey(KeyCode.U)) { FlyCam.self.MoveUp(); } else if (Input.GetKey(KeyCode.O)) { FlyCam.self.MoveDown(); } if (Input.GetKey(KeyCode.Keypad8)) { FlyCam.self.RotateUp(); } else if (Input.GetKey(KeyCode.Keypad2)) { FlyCam.self.RotateDown(); } if (Input.GetKey(KeyCode.Keypad4)) { FlyCam.self.RotateLeft(); } else if (Input.GetKey(KeyCode.Keypad6)) { FlyCam.self.RotateRight(); } if (Input.GetKey(KeyCode.Keypad1)) { FlyCam.self.TiltLeft(); } else if (Input.GetKey(KeyCode.Keypad3)) { FlyCam.self.TiltRight(); } } // End FlyCam Controls // handle power up/down if (Input.GetKeyDown(KeyCode.RightBracket) || Input.GetKeyDown(KeyCode.LeftBracket) || Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.Q)) { SingedMessages.SendStartAudioLoop( gameObject, "PowerAudio", TankSoundKind.tank_power_UpDown_LOOP); } if (Input.GetKeyUp(KeyCode.RightBracket) || Input.GetKeyUp(KeyCode.LeftBracket) || Input.GetKeyUp(KeyCode.E) || Input.GetKeyUp(KeyCode.Q)) { SingedMessages.SendStopAudioLoop( gameObject, "PowerAudio"); } if (Input.GetKey(KeyCode.RightBracket) || Input.GetKey(KeyCode.E)) { var magnifier = (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) ? 3f : 1f; shotPower += magnifier * shotPowerModifier; } if (Input.GetKey(KeyCode.LeftBracket) || Input.GetKey(KeyCode.Q)) { var magnifier = (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) ? 3f : 1f; shotPower -= magnifier * shotPowerModifier; } shotPower = Mathf.Clamp(shotPower, 0f, maxShotPower); // handle changing shot if (Input.GetKeyDown(KeyCode.Comma) || Input.GetKeyDown(KeyCode.X)) { selectedShot = shotInventory.PrevAvailableShot(selectedShot); Debug.Log("now using shot: " + selectedShot); } if (Input.GetKeyDown(KeyCode.Period) || Input.GetKeyDown(KeyCode.C)) { selectedShot = shotInventory.NextAvailableShot(selectedShot); Debug.Log("now using shot: " + selectedShot); } // Shoot already ... when shot is fired, finish this coroutine; if (Input.GetKeyDown(KeyCode.Space)) { //Debug.Log("space is down, calling CmdFire"); // sanity check for ammo SingedMessages.SendStopAudioLoop( gameObject, "PowerAudio"); SingedMessages.SendStopAudioLoop( gameObject, "HorizontalMovementAudio"); SingedMessages.SendStopAudioLoop( gameObject, "VerticalMovementAudio"); if (shotInventory.GetAvailable(selectedShot) > 0) { SingedMessages.SendPlayAudioClip(tankSoundKind); speech = BarkManager.self.GetTheShotOneLinerPath(selectedShot, charVoice); SingedMessages.SendPlayAudioClip(speech, false, 0.75f); CmdFire(shotPower, selectedShot); // decrease ammo count shotInventory.ServerModify(selectedShot, -1); // check to see if we still have availability for selected shot if (shotInventory.GetAvailable(selectedShot) <= 0) { selectedShot = shotInventory.NextAvailableShot(selectedShot); Debug.Log("now using shot: " + selectedShot); } } else { Debug.Log("out of ammo for shottype " + selectedShot); } yield break; } if (Input.GetKeyDown(KeyCode.O)) { speech = BarkManager.self.GetTheShotOneLinerPath(selectedShot, charVoice); } // handle horizontal turret movement var newRotation = Input.GetAxis("Horizontal"); if (!Mathf.Approximately(newRotation, 0f)) { if (!isHorizontalAxisInUse) { SingedMessages.SendStartAudioLoop( gameObject, "HorizontalMovementAudio", TankSoundKind.tank_movement_LeftRight_LOOP_01); isHorizontalAxisInUse = true; } } else { if (isHorizontalAxisInUse) { SingedMessages.SendStopAudioLoop( gameObject, "HorizontalMovementAudio"); isHorizontalAxisInUse = false; } } if (model != null) { model.tankRotation += newRotation * Time.deltaTime * rotationSpeedVertical; } // handle vertical turret movement var newElevation = Input.GetAxis("Vertical"); if (!Mathf.Approximately(newElevation, 0f)) { if (!isVerticalAxisInUse) { SingedMessages.SendStartAudioLoop( gameObject, "VerticalMovementAudio", TankSoundKind.tank_movement_UpDown_LOOP_01); isVerticalAxisInUse = true; } } else { if (isVerticalAxisInUse) { SingedMessages.SendStopAudioLoop( gameObject, "VerticalMovementAudio"); isVerticalAxisInUse = false; } } if (model != null) { model.turretElevation += newElevation * Time.deltaTime * rotationSpeedHorizontal; model.turretElevation = Mathf.Clamp(model.turretElevation, minTurretElevation, maxTurretElevation); } // continue on next frame yield return(null); } }
public AudioClip GetTheShotOneLiner(ProjectileKind shot, int voice) { return(Resources.Load <AudioClip>(GetTheShotOneLinerPath(shot, voice))); }
public bool TryGetObject(ProjectileKind info, out Projectile obj) { obj = GetObject(info); return(obj != null); }
public string GetTheShotOneLinerPath(ProjectileKind shot, int voice) { int anyNumber = UnityEngine.Random.Range(0, 10), lineIndex, voiceIndex; string theLine; if (anyNumber > 5) { switch (shot) { case ProjectileKind.acorn: if (currentAcornLineIndex >= totalAcornLines) { currentAcornLineIndex = 0; RandomizeQueue(acornIndexQueue); } lineIndex = acornIndexQueue[currentAcornLineIndex]; voiceIndex = totalAcornLines * voice; acornOneLiner = (AcornOneLinersKind)(voiceIndex + lineIndex); theLine = "OneLiners/" + acornOneLiner; currentAcornLineIndex++; return(theLine); case ProjectileKind.artilleryShell: if (currentMissileLineIndex >= totalMissileLines) { currentMissileLineIndex = 0; RandomizeQueue(missileIndexQueue); } lineIndex = missileIndexQueue[currentMissileLineIndex]; voiceIndex = totalMissileLines * voice; missileOneLiner = (MissileOneLinersKind)(voiceIndex + lineIndex); theLine = "OneLiners/" + missileOneLiner; currentMissileLineIndex++; return(theLine); case ProjectileKind.sharkToothCluster: if (currentSharktoothLineIndex >= totalSharktoothLines) { currentSharktoothLineIndex = 0; RandomizeQueue(sharktoothIndexQueue); } lineIndex = sharktoothIndexQueue[currentSharktoothLineIndex]; voiceIndex = totalSharktoothLines * voice; sharktoothOneLiner = (SharktoothOneLinersKind)(voiceIndex + lineIndex); theLine = "OneLiners/" + sharktoothOneLiner; currentSharktoothLineIndex++; return(theLine); case ProjectileKind.pillarShot: if (currentPillarLineIndex >= totalPillarLines) { currentPillarLineIndex = 0; RandomizeQueue(pillarIndexQueue); } lineIndex = pillarIndexQueue[currentPillarLineIndex]; voiceIndex = totalPillarLines * voice; pillarOneLiner = (PillarOneLinersKind)(voiceIndex + lineIndex); theLine = "OneLiners/" + pillarOneLiner; currentPillarLineIndex++; return(theLine); case ProjectileKind.beetMissile: if (currentBeetLineIndex >= totalBeetLines) { currentBeetLineIndex = 0; RandomizeQueue(beetIndexQueue); } lineIndex = beetIndexQueue[currentBeetLineIndex]; voiceIndex = totalBeetLines * voice; beetOneLiner = (BeetOneLinersKind)(voiceIndex + currentBeetLineIndex); theLine = "OneLiners/" + beetOneLiner; currentBeetLineIndex++; return(theLine); case ProjectileKind.mushboom: if (currentMushboomLineIndex >= totalMushboomLines) { currentMushboomLineIndex = 0; RandomizeQueue(mushboomIndexQueue); } lineIndex = mushboomIndexQueue[currentMushboomLineIndex]; voiceIndex = totalMushboomLines * voice; mushboomOneLiner = (MushboomOneLinersKind)(voiceIndex + currentMushboomLineIndex); theLine = "OneLiners/" + mushboomOneLiner; currentMushboomLineIndex++; return(theLine); case ProjectileKind.teleportBall: if (currentTeleportLineIndex >= totalTeleportLines) { currentTeleportLineIndex = 0; RandomizeQueue(teleportIndexQueue); } lineIndex = teleportIndexQueue[currentTeleportLineIndex]; voiceIndex = totalTeleportLines * voice; teleportOneLiner = (TeleportOneLinersKind)(voiceIndex + currentTeleportLineIndex); theLine = "OneLiners/" + teleportOneLiner; currentTeleportLineIndex++; return(theLine); default: if (currentCannonLineIndex >= totalCannonLines) { currentCannonLineIndex = 0; RandomizeQueue(cannonIndexQueue); } lineIndex = cannonIndexQueue[currentCannonLineIndex]; voiceIndex = totalCannonLines * voice; cannonOneLiner = (CannonOneLinersKind)(voiceIndex + currentCannonLineIndex); theLine = "OneLiners/" + cannonOneLiner; currentCannonLineIndex++; return(theLine); } } else { if (currentAnyLineIndex >= totalAnyLines) { currentAnyLineIndex = 0; RandomizeQueue(anyIndexQueue); } lineIndex = anyIndexQueue[currentAnyLineIndex]; voiceIndex = totalAnyLines * voice; anyOneLiner = (AnyOneLinersKind)(voiceIndex + currentAnyLineIndex); theLine = "OneLiners/" + anyOneLiner; currentAnyLineIndex++; return(theLine); } }
public void RpcModify(ProjectileKind kind, int amount) { Modify(kind, amount); }
public int GetAvailable(ProjectileKind shot) { return(ammoCounts[(int)shot]); }
public ProjectileKind NextAvailableShot(ProjectileKind currentShot) { return(FindAvailableShot(currentShot, 1)); }
public ProjectileKind PrevAvailableShot(ProjectileKind currentShot) { return(FindAvailableShot(currentShot, -1)); }
public void SetProjectileKind(ProjectileKind kind) { myKind = kind; }
public override object Evaluate(List <string> args, ExpressionEvaluator evaluator, Creature player, Target target, CastedSpell spell, RollResults dice = null) { ExpectingArguments(args, 3, 11); if (player == null || spell == null) { return(null); } string effectName = Expressions.GetStr(args[0]); ProjectileKind projectileKind = ProjectileKind.EachTarget; int projectileCount = 1; float speed = 20; FireCollisionEventOn fireCollisionEventOn = FireCollisionEventOn.EachImpact; float launchTimeVariance = 0; float targetVariance = 0; ProjectileSizeOption projectileSize = ProjectileSizeOption.ConstantSize; float projectileSizeMultiplier = 1; float bezierPathMultiplier = 1; if (args.Count > 1) { projectileKind = Expressions.Get <ProjectileKind>(args[1]); if (args.Count > 2) { int.TryParse(args[2], out projectileCount); if (args.Count > 3) { float.TryParse(args[3], out speed); if (args.Count > 4) { fireCollisionEventOn = Expressions.Get <FireCollisionEventOn>(args[4]); if (args.Count > 5) { float.TryParse(args[5], out launchTimeVariance); if (args.Count > 6) { float.TryParse(args[6], out targetVariance); if (args.Count > 7) { projectileSize = Expressions.Get <ProjectileSizeOption>(args[7]); if (args.Count > 8) { float.TryParse(args[8], out projectileSizeMultiplier); if (args.Count > 9) { float.TryParse(args[9], out bezierPathMultiplier); } } } } } } } } } ProjectileEffectEventArgs ea = new ProjectileEffectEventArgs(effectName, spell.ID, player.taleSpireId, speed, projectileCount, projectileKind, fireCollisionEventOn, launchTimeVariance, targetVariance, target, projectileSize, projectileSizeMultiplier, bezierPathMultiplier); LaunchProjectile?.Invoke(null, ea); return(null); }
public void CollectLoot(ProjectileKind ammo, int ammoCount) { lootPool.Add(ammo); lootCount.Add(ammoCount); }