// 하나 하나 찾기 public GameObject FindCreatur(Vector3Int cellPos) { foreach (GameObject obj in _objects.Values) { CreatureController cc = obj.GetComponent <CreatureController>(); if (cc == null) { continue; } if (cc.CellPos == cellPos) { return(obj); } } return(null); }
protected override void MoveToNextPos() { Vector3Int destPos = CellPos; switch (_dir) { case MoveDir.Up: destPos += Vector3Int.up; break; case MoveDir.Down: destPos += Vector3Int.down; break; case MoveDir.Left: destPos += Vector3Int.left; break; case MoveDir.Right: destPos += Vector3Int.right; break; } if (Managers.Map.CanGo(destPos)) { GameObject go = Managers.Object.Find(destPos); if (go == null) { CellPos = destPos; } else { CreatureController cc = go.GetComponent <CreatureController>(); if (cc != null) { cc.OnDamaged(); } Managers.Resource.Destroy(gameObject); } } else { Managers.Resource.Destroy(gameObject); } }
public IEnumerator Attack(TileController originTile, TileController targetTile) { enemy = targetTile.creature; yield return(StartCoroutine(ApproachTarget(originTile, targetTile))); animatorController.SetTrigger("Attacks"); finishedInteractionAnimation = false; while (!finishedInteractionAnimation) { yield return(null); } if (enemy.isDefending) { yield return(StartCoroutine(TakeDamage(defendingDamage))); yield return(StartCoroutine(enemy.TakeDamage(defendingDamage))); } else { yield return(StartCoroutine(enemy.TakeDamage(GameManager.instance.maxHealth))); } if (enemy.CheckIfDie()) { yield return(StartCoroutine(enemy.Die())); } else { targetTile = originTile; enemy.creatureTransform.rotation = Quaternion.identity; } if (CheckIfDie()) { ActionsManager.instance.FinishAction(); } else { yield return(StartCoroutine(MoveToTarget(targetTile))); SetToTired(false); } }
public void CheckIfConverted(CreatureController savior) { PlayerController saviorPlayer = savior.belongsToPlayer; if (savior.oppressedByPlayer != null) { saviorPlayer = savior.oppressedByPlayer; } if (influencedByPlayer == null) { saviorPlayer.attemptingToConvert.Add(this); influencedByPlayer = saviorPlayer; inDoubtBlinkLoop = InDoubt(); StartCoroutine(inDoubtBlinkLoop); } else if (influencedByPlayer == saviorPlayer) { StopCoroutine(inDoubtBlinkLoop); saviorPlayer.attemptingToConvert.Remove(this); belongsToPlayer.LoseCreature(this); ChangeTeam(saviorPlayer); } else if (savior.belongsToPlayer == belongsToPlayer) { influencedByPlayer.attemptingToConvert.Remove(this); StopCoroutine(inDoubtBlinkLoop); ChangeTeam(belongsToPlayer); } else { StopCoroutine(inDoubtBlinkLoop); influencedByPlayer.attemptingToConvert.Remove(this); saviorPlayer.attemptingToConvert.Add(this); influencedByPlayer = saviorPlayer; inDoubtBlinkLoop = InDoubt(); StartCoroutine(inDoubtBlinkLoop); } StartCoroutine(dialogCanvas.DisplayMessageForTime("Oh Boy...")); }
public GameObject Find(Func <GameObject, bool> condition) { foreach (GameObject obj in _objects.Values) { CreatureController cc = obj.GetComponent <CreatureController>(); if (cc == null) { continue; } if (condition.Invoke(obj)) { return(obj); } } return(null); }
public static void S_SkillHandler(PacketSession session, IMessage packet) { S_Skill skillPacket = packet as S_Skill; GameObject go = Managers.Object.FindById(skillPacket.ObjectId); if (go == null) { return; } CreatureController cc = go.GetComponent <CreatureController>(); if (cc != null) { cc.UseSkill(skillPacket.Info.SkillId); } }
public static void S_ChangeHpHandler(PacketSession session, IMessage packet) { S_ChangeHp changePacket = packet as S_ChangeHp; GameObject go = Managers.Object.FindById(changePacket.ObjectId); if (go == null) { return; } CreatureController cc = go.GetComponent <CreatureController>(); if (cc != null) { cc.Hp = changePacket.Hp; } }
void Start() { m_InputHandler = GetComponent <InputHandler>(); m_CreatureController = GetComponent <CreatureController>(); m_Nest = transform.parent.gameObject; m_NestXPos = m_Nest.transform.position.x; m_SpiritState = new SpiritState(this); m_IdleState = new IdleState(this); m_RoamingState = new RoamingState(this); m_CurrentState = m_IdleState; if (m_CurrentState != null && !m_InputHandler.PlayerControlled) { m_CurrentState.Enter(); } }
public static void S_DieHandler(PacketSession session, IMessage packet) { S_Die diePacket = packet as S_Die; GameObject go = Managers.Object.FindById(diePacket.ObjectId); if (go == null) { return; } CreatureController cc = go.GetComponent <CreatureController>(); if (cc != null) { cc.Hp = 0; cc.OnDead(); } }
public void HandleCreatureClick(CreatureController creature) { // Check for target selection and update creature displays accordingly if (targets.Contains(creature)) { targets.Remove(creature); creature.SetTargetingArrowDisplay(false); } else { targets.Add(creature); creature.SetTargetingArrowDisplay(true); } // Update UI if all conditions for casting a spell have been met CheckCastReady(); }
private bool SetHost(Transform newHost) { if (newHost.CompareTag("Creature")) { if (host != null) { host.HostRelease(); } host = newHost.GetComponent <CreatureController>(); playerInputManager.playerCamera.LookAt = host.HostTakeOver().transform; transform.SetParent(host.transform, worldPositionStays: false); playerInputManager.playerCamera.m_XAxis.Value = host.GetRotation().eulerAngles.y; return(true); } return(false); }
void CheckInstances() { GameObject MapInfo = GameObject.Find("_MapInfo"); if (playerInstance == null) { playerInstance = Instantiate(PlayerPrefab, Vector3.zero, Quaternion.identity).GetComponent <PlayerController>(); } if (birdInstance == null) { birdInstance = Instantiate(BirdPrebab).GetComponent <CreatureController>(); } if (hudInstance == null) { hudInstance = Instantiate(HUDPrefab).GetComponent <HUDManager>(); } if (soundInstance == null) { soundInstance = this.GetComponent <SoundsManager>(); } if (checkpointManager == null) { checkpointManager = this.GetComponent <CheckPointManager>(); } if (cameraInstance == null) { cameraInstance = Instantiate(CameraPrefab).GetComponent <CameraController>(); Camera.LookAt(playerInstance.transform); } if (entityInstance == null && MapInfo != null) { if (MapInfo.TryGetComponent <EntityManager>(out EntityManager em)) { entityInstance = em; } } }
public static void S_SkillHandler(PacketSession session, IMessage packet) { S_Skill skillPacket = packet as S_Skill; // 여기서 찾은 PlayerId가 꼭 나라는 보장은 없다. 스킬은 아무나 쓰니깐 GameObject go = Managers.Object.FindById(skillPacket.ObjectId); if (go == null) { return; } // 정보를 고치기 위해 CreatureController에 접근 CreatureController pc = go.GetComponent <CreatureController>(); if (pc != null) { pc.UseSkill(skillPacket.Info.SkillId); } }
public static void S_DieHandler(PacketSession session, IMessage packet) { S_Die diePacket = packet as S_Die; // 여기서 찾은 PlayerId가 꼭 나라는 보장은 없다. 스킬은 아무나 쓰니깐 GameObject go = Managers.Object.FindById(diePacket.ObjectId); if (go == null) { return; } CreatureController cc = go.GetComponent <CreatureController>(); if (cc != null) { cc.Hp = 0; cc.OnDead(); // 해당 크리처를 죽임 } }
IEnumerator CoStartPunch() { // 피격 판정 GameObject go = Managers.Object.Find(GetFrontCellPos()); if (go != null) { CreatureController cc = go.GetComponent <CreatureController>(); if (cc != null) { cc.OnDamaged(); } } // 대기 시간 yield return(new WaitForSeconds(0.5f)); State = CreatureState.Moving; _coSkill = null; }
public void LoseCreature(CreatureController creature) { if (controlledCreatures.Contains(creature)) { controlledCreatures.Remove(creature); if (creature.occupiedTile.resource != null) { controlledStones--; } } else if (oppressedCreatures.Contains(creature)) { oppressedCreatures.Remove(creature); if (creature.occupiedTile.resource != null) { controlledStones--; } } }
private void HandlePickUp() { if (CarriedCreature == null) { if (ExtractionPoint != null) { ExtractionStarted = true; ExtractionTimeRemaining = MaxExtractionTime; } else { Collider[] colliders = Physics.OverlapSphere(transform.position, PickUpRadius); if (colliders.Any(c => c.tag == "Creature")) { CreatureController creature = colliders.First(c => c.tag == "Creature").GetComponentInParent <CreatureController>(); CarriedCreature = creature ?? throw new UnityException("Found creature, but it doesn't have a controller"); GameManager.Instance.RaiseSecurityAwareness(); CarriedCreature.transform.SetParent(transform); CarriedCreature.transform.position = CarryPosition.position; Animator.SetBool(AnimatorParams.Carrying, true); } } } else { if (ExtractionPoint != null) { ExtractionPoint.ReleaseCreature(CarriedCreature); } else { CarriedCreature.transform.position = DropPosition.position; } Animator.SetBool(AnimatorParams.Carrying, false); CarriedCreature.transform.SetParent(transform.parent); CarriedCreature = null; } }
public static void S_ChangeHpHandler(PacketSession session, IMessage packet) { S_ChangeHp changePacket = packet as S_ChangeHp; // 여기서 찾은 PlayerId가 꼭 나라는 보장은 없다. 스킬은 아무나 쓰니깐 GameObject go = Managers.Object.FindById(changePacket.ObjectId); if (go == null) { return; } CreatureController cc = go.GetComponent <CreatureController>(); if (cc != null) { // 체력을 깎자 cc.Hp = changePacket.Hp; // ui 갱신도 같이 됨 // UI 갱신 Debug.Log($"ChangeHP : {changePacket.Hp}"); } }
public CreatureController DuplicateToTarget(TileController targetTile) { Transform target = targetTile.spawnPoint; Vector3 newPosition = transform.position + (0.3f * (target.position - transform.position)); oppressScript.SetAllActive(); GameObject instance = Instantiate(gameObject, newPosition, Quaternion.identity) as GameObject; oppressScript.SetAllFalse(); CreatureController newCreature = instance.GetComponent <CreatureController> (); newCreature.ChangeTeam(belongsToPlayer); // Assign creature to new tile. newCreature.occupiedTile = targetTile; SetToTired(halfTired: false); return(newCreature); }
void InspectCreature(RaycastHit2D hit) { sprite = hit.collider.gameObject.GetComponent <SpriteRenderer>(); this.gameObject.transform.GetChild(0).GetChild(0).GetChild(1).GetComponent <Image>().sprite = sprite.sprite; creatureStats = hit.collider.gameObject.GetComponent <CreatureStatsManager>(); creatureController = hit.collider.gameObject.GetComponent <CreatureController>(); this.gameObject.transform.GetChild(0).GetChild(0).GetChild(2).GetComponent <Text>().text = "ST: " + creatureStats.stats.stats.strength; this.gameObject.transform.GetChild(0).GetChild(0).GetChild(3).GetComponent <Text>().text = "DX: " + creatureStats.stats.stats.dexterity; this.gameObject.transform.GetChild(0).GetChild(0).GetChild(4).GetComponent <Text>().text = "IQ: " + creatureStats.stats.stats.intelligence; this.gameObject.transform.GetChild(0).GetChild(0).GetChild(5).GetComponent <Text>().text = "FT: " + creatureStats.stats.stats.fitness; this.gameObject.transform.GetChild(0).GetChild(0).GetChild(6).GetComponent <Text>().text = "Name: " + creatureStats.stats.GivenName; this.gameObject.transform.GetChild(0).GetChild(0).GetChild(7).GetComponent <Text>().text = "Species: " + creatureStats.stats.species; this.gameObject.transform.GetChild(0).GetChild(0).GetChild(8).GetComponent <Button>().onClick.AddListener(delegate { Rename(creatureStats); }); this.gameObject.transform.GetChild(0).GetChild(0).GetChild(8).GetChild(1).gameObject.SetActive(false); this.gameObject.transform.GetChild(0).GetChild(0).GetChild(8).GetChild(2).gameObject.SetActive(false); this.gameObject.transform.GetChild(0).GetChild(0).GetChild(10).GetComponent <Text>().text = creatureStats.stats.bio; this.gameObject.transform.GetChild(0).GetChild(0).GetChild(11).GetComponent <Button>().onClick.AddListener(Leash); }
public void objectDetailsText(GameObject gameObject) { string text = ""; int eAmount = 0; int mAmount = 0; Text details_text = details_object.GetComponent <Text>(); if (gameObject.tag == "Block") { BlockController blockController = gameObject.GetComponent <BlockController>(); eAmount = blockController.energyAmount; mAmount = blockController.magicAmount; text = "Energy: " + eAmount + "\n" + "Magic: " + mAmount; details_text.text = text; } else if (gameObject.tag == "Creature") { CreatureController creatureController = gameObject.GetComponent <CreatureController>(); eAmount = creatureController.getCarryingAmount(); text = "Name: " + gameObject.name + "\nEnergy: " + eAmount + "\n" + "Magic: " + mAmount; details_text.text = text; } }
void EnterPlayMode() { if (playMode_Enabled) { return; } Debug.Log("Entering PLAYMODE"); playMode_Enabled = true; GameObject[] sortedSpeedList = wb.GetListOfCurrentCreatures(); string str_list = ""; foreach (GameObject c in sortedSpeedList) { str_list += c.GetComponent <CreatureClass>().getName() + ", "; } Debug.Log(str_list); CreatureController cc = sortedSpeedList[0].GetComponent <CreatureController>(); SetSelectorPosition(cc.getPosX(), cc.getPosY()); //Show UI UI_C.ShowUI_PLAYMODE(); GC.SetCreatureList(sortedSpeedList); }
public bool MoveCreature(CreatureController creatureController, Cell targetCell) { if (creatureController.IsMoving) { Debug.Log("Creature is already moving"); return(false); } if (targetCell.GetCreaturesCount() > 0) { Debug.Log("There is already some creature in the cell"); return(false); } var sourceCell = creatureController.ParentCell; sourceCell.MoveCreatureFromThis(creatureController); targetCell.MoveCreatureToThis(creatureController); creatureController.IsMoving = true; return(true); }
public void CreatureReturnedToBarn(CreatureController creatureController) { score = score + creatureController.GetValue(); }
public void OnCreatureDeath(CreatureController c) { OnCreatureDie?.Invoke(c); }
private void Awake() { Instance = this; }
public void loadcreature(string creature, GameObject myplayer, GameObject otherplayer, Vector3 initPos = default(Vector3), string Tag = default(string), int textureCount = default(int)) { string path = "Creatures/" + creature + "/" + creature; //+ ".FBX"; GameObject inputCreature = (GameObject)Resources.Load(path, typeof(GameObject)); string[] filelines = File.ReadAllLines("assets/Resources/Creatures/" + creature + "/Scale.txt"); for (int i = 0; i < filelines.Length; i++) { string[] coord = filelines[i].Split(";"[0]); coord0 = float.Parse(coord[0]) * 0.01f; //changed by /100 already coord1 = float.Parse(coord[1]) * 0.01f; //changed by /100 already coord2 = float.Parse(coord[2]) * 0.01f; //changed by /100 already } inputCreature.transform.localScale = new Vector3(coord0, coord1, coord2); new_creature = (GameObject)GameObject.Instantiate(inputCreature); new_creature.AddComponent <Footsteps>(); new_creature.AddComponent <CreatureController>(); //new_creature.layer = 8; CreatureController cc = new_creature.GetComponent <CreatureController>(); cc.target = myplayer.transform; cc.target2 = otherplayer.transform; cc.creaturesHeight = creaturesHeight; if (textureCount == 1) { cc.changeMesh = true; cc.textureCount = 1; } if (initPos == new Vector3(0, 0, 0)) { new_creature.transform.position = new Vector3(myplayer.transform.position.x, creaturesHeight, myplayer.transform.position.z); } else { new_creature.transform.position = initPos; } new_creature.transform.rotation = Quaternion.LookRotation(myplayer.transform.position - new_creature.transform.position); childRenderer = new_creature.GetComponentsInChildren <SkinnedMeshRenderer>(); childRenderer[0].material.color = new Color(1, 1, 1); string path_texture1 = "Creatures/" + creature + "/" + creature + "_1"; // + ".png"; string path_texture2 = "Creatures/" + creature + "/" + creature + "_2"; // + ".png"; string path_texture3 = "Creatures/" + creature + "/" + creature + "_3"; // + ".png"; string path_texture4 = "Creatures/" + creature + "/" + creature + "_4"; // + ".png"; current_textures.Clear(); current_textures.Add(Resources.Load <Texture>(path_texture1)); current_textures.Add(Resources.Load <Texture>(path_texture2)); current_textures.Add(Resources.Load <Texture>(path_texture3)); current_textures.Add(Resources.Load <Texture>(path_texture4)); if (textureCount == default(int)) { childRenderer[0].material.mainTexture = current_textures[0]; } else { childRenderer[0].material.mainTexture = current_textures[textureCount]; } string path_controller = "Creatures/" + creature + "/" + creature; // + ".controller"; Animator anim1 = new_creature.GetComponent <Animator>(); anim1.runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>(path_controller); new_creature.AddComponent <AudioSource>(); new_creature.AddComponent <AudioSource>(); if (Tag == default(string)) { if (myplayer.name == "Player1") { new_creature.tag = "creature1"; } else { new_creature.tag = "creature2"; } } else { new_creature.tag = Tag; } creature_scale = new_creature.transform.localScale.x * 0.05f; counter_scale = 100; }
public IdleState(CreatureController creature) : base(creature) { }
protected CollectBehaviour(CreatureState state, CreatureController creature) { State = state; Creature = creature; }
public PlayState(CreatureController creature) : base(creature) { }