//---------------------------------------------------------------------------- // Init player //---------------------------------------------------------------------------- private void Awake() { // Assert required components LootComponent lootComponent = GetComponent <LootComponent>(); Debug.Assert(lootComponent != null, "You haven't assign loot component to the player!"); CannonComponent cannonComponent = GetComponent <CannonComponent>(); Debug.Assert(cannonComponent != null, "You haven't assign cannon component to the player!"); Debug.Assert(m_manager != null, "You haven't assign gameplay manager to the player."); Debug.Assert(m_respawnObject != null, "You haven't assign respawn object to the player."); // Upgrades ResetUpgrades(); m_characterRadius = GetComponent <CapsuleCollider>().radius; m_characterHeight = GetComponent <CapsuleCollider>().height; m_characterCenter = GetComponent <CapsuleCollider>().center; // Init Data score = 0; m_stamina = GetComponent <Invector.vCharacterController.vActions.vSwimming>().stamina; m_characterSwimSpeed = GetComponent <Invector.vCharacterController.vActions.vSwimming>().swimForwardSpeed; }
//---------------------------------------------------------------------------- // Collision detected enter trigger //---------------------------------------------------------------------------- protected void OnTriggerEnter(Collider other) { Player player = other.gameObject.GetComponent <Player>(); if (player != null && // Collier is player (player.GetComponent <LootComponent>().GetLootCount() < player.GetComponent <LootComponent>().m_maxLoot)) // Player's current loot count has not hit max loot yet { if (m_LootType == LootType.Treasure) { LootComponent playerLootComponent = player.GetComponent <LootComponent>(); if (playerLootComponent != null) { playerLootComponent.Loot(m_value); Destroy(this.gameObject); // Kill this loot object } } else { CannonComponent playerCannonComponent = player.GetComponent <CannonComponent>(); if (playerCannonComponent != null) { playerCannonComponent.AddCannon(m_value); Destroy(this.gameObject); // Kill this loot object } } } }
private void Start() { thisRigidbody = GetComponent <Rigidbody>(); thisCamera = GetComponentInChildren <Camera>(); thisCamera.transform.localPosition = firstPersonPos; cannonRef = GetComponentInChildren <CannonComponent>(); }
private void SpawnBullet(CannonComponent cannon) { for (int i = 0; i < cannon.cannonTransform.Length; i++) { UnityEngine.Object.Instantiate(cannon.bulletPrefab, cannon.cannonTransform[i].position, cannon.cannonTransform[i].rotation); } }
private void AdjustObjectInfoAndImage(int index) { if (m_objectInfoPanel.activeSelf) { Language lan = GameManager.s_instance.gameLanguage; m_objectName.text = lan == Language.kEnglish ? s_kTagNames[index] + " Info" : s_kTagNamesInChinese[index] + " 信息"; m_objectImage.sprite = m_objectIcons[index]; Ship shipComp = m_hit.collider.GetComponent <Ship>(); m_lootText.text = shipComp ? shipComp.minDropValue.ToString() + " ~ " + shipComp.maxDropValue.ToString() : "?"; CannonComponent cannon = m_hit.collider.GetComponent <CannonComponent>(); m_cannonballText.text = cannon ? cannon.cannonballCount.ToString() : "?"; } }
public PlanetEntity(GameEntity planetE) { Planet = planetE.planet; Position = planetE.position; Mass = planetE.mass; Health = planetE.health; if (planetE.hasCannon) { Cannon = planetE.cannon; } if (planetE.hasCooldownTimer) { CooldownTimer = planetE.cooldownTimer; } }
private int ReSpawnBullet(int index, CannonComponent cannon) { var puc = PostUpdateCommands; for (int i = 0; i < cannon.cannonTransform.Length; i++) { if (index < bulletData.Length) { puc.RemoveComponent <IdleComponent>(bulletData.Entity[index]); bulletData.Transform[index].position = cannon.cannonTransform[index].position; bulletData.Transform[index].rotation = cannon.cannonTransform[index].rotation; index += 1; } } return(index); }