public void CreateThings(bool deathmatch) { GameObject holder = new GameObject("MapThings"); holder.transform.SetParent(transform); foreach (Thing t in MapLoader.things) { if (!deathmatch) { if ((t.flags & (1 << 4)) != 0) { continue; } } if (!_things.ContainsKey(t.thingType)) { Debug.Log("Unknown thing type (" + t.thingType + ")"); continue; } GameObject thingObject = Instantiate(_things[t.thingType]); thingObject.transform.SetParent(holder.transform); ThingController tc = thingObject.GetComponent <ThingController>(); if (tc != null) { tc.thing = t; tc.Init(); activeThings.Add(tc); } } }
private void Awake() { mr = GetComponentInChildren <SkinnedMeshRenderer>(); if (mr == null) { Debug.LogError("CharacterMaterialController: Awake: Could not find skinned mesh renderer"); return; } materialProperties = new MaterialPropertyBlock(); ThingController thingController = GetComponent <ThingController>(); if (thingController != null) { thingController.OnMouseEnter.AddListener(() => { Highlight(true); }); thingController.OnMouseLeave.AddListener(() => { Highlight(false); }); } if (DeathMaterial != null) { MonsterCharacter character = GetComponent <MonsterCharacter>(); if (character != null) { character.OnDeath.AddListener(OnDeath); } } materialProperties.SetColor("_OutlineColor", OutlineColor); materialProperties.SetFloat("_Outline", OutlineWidthDisabled); mr.SetPropertyBlock(materialProperties); enabled = false; }
private void DrawThing(ThingController controller) { if (GUILayout.Button("Show Thing Data")) { thingHider.target = !thingHider.target; } if (EditorGUILayout.BeginFadeGroup(thingHider.faded)) { EditorGUILayout.LabelField("{"); EditorGUI.indentLevel++; foreach (var prop in typeof(Thing).GetProperties()) { GUILayout.Label(prop.Name + ":"); GUILayout.Label(prop.GetValue(controller.thing, null).ToString()); GUILayout.Label(""); } EditorGUI.indentLevel--; EditorGUILayout.LabelField("}"); } EditorGUILayout.EndFadeGroup(); }
private void Awake() { thingController = GetComponent <ThingController>(); physicsBody = GetComponent <Rigidbody2D>(); HitPoints = MaxHitPoints; ChargePoints = MaxChargePoints; //for monsters without weapons OnLookDirection = RotateTowardsWantDirection; }
private void Awake() { character = GetComponent <MonsterCharacter>(); thing = GetComponent <ThingController>(); refreshTargetTimer = Random.value; GetNewTarget = DefaultGetNewTarget; OnAwake(); }
// Use this for initialization void Start() { roundController = FindObjectOfType <RoundController>(); roomContraller = FindObjectOfType <RoomContraller>(); initMapObject = FindObjectOfType <initMap>(); loadingManager = FindObjectOfType <LoadingManager>(); storyController = FindObjectOfType <StoryController>(); thingController = FindObjectOfType <ThingController>(); eventController = FindObjectOfType <EventController>(); taskMananger = FindObjectOfType <TaskMananger>(); }
private void Awake() { behavior = GetComponent <Behavior>(); character = GetComponent <MonsterCharacter>(); thing = GetComponent <ThingController>(); behavior.OnLoseTarget.AddListener(() => { TakeOver(); }); behavior.OnGainTarget.AddListener(() => { behavior.Restart(); Active = false; }); Messaging.Player.PlayerEnterRoom.AddListener((i) => { LastKnownPlayerRoom = i; }); }
void Awake() { for (int i = 0; i < animationSets.Length; i++) { animationSets[i].Init(); animationSetDictionary.Add(animationSets[i].animationId, animationSets[i]); } SetAnimationSet("IDLE"); thingController = GetComponent <ThingController>(); StartCoroutine(DoAnimationFrame()); }
void Start() { _color.a = 1; _color.r = 1; _color.g = 1; _color.b = 1; TC = gameObject.GetComponent <ThingController> (); GameObject obj = GameObject.Find("GameController"); GC = obj.GetComponent <GameController>(); text = GameObject.Find("QuickTimeEventsText").GetComponent <Text>(); }
public void CreateThings(bool deathmatch) { GameObject holder = new GameObject("MapThings"); holder.transform.SetParent(transform); foreach (Thing t in MapLoader.things) { if (!deathmatch) { if ((t.flags & (1 << 4)) != 0) { continue; } } if (!thingPrefabs.ContainsKey(t.thingType)) { Debug.Log("Unknown thing type (" + t.thingType + ")"); continue; } GameObject thingObject = Instantiate(thingPrefabs[t.thingType]); thingObject.transform.SetParent(holder.transform); ThingController tc = thingObject.GetComponent <ThingController>(); if (tc != null) { tc.transform.position = new Vector3(t.posX, 0, t.posY); //height will be set by tc.Init() tc.transform.rotation = Quaternion.Euler(0, t.facing, 0); tc.Init(); if ((t.flags & (1 << 3)) != 0) { if (tc.CurrentBehavior != null) { tc.CurrentBehavior.deaf = true; } } } } }
public StateController(Actor actor, Dictionary <string, PICTURES> allSprites, AudioSource audioSource, GameObject obj, Light light) { state = actor.actorStates["Spawn"]; this.actor = actor; go = obj; brightLight = light; StartUV = go.GetComponent <MeshFilter>().mesh.uv; //Original UVS FlipUV = go.GetComponent <MeshFilter>().mesh.uv; //Original UVS again? System.Array.Reverse(FlipUV); //Just kidding, flipped them tCont = go.transform.parent.gameObject.GetComponent <ThingController>(); // get a list of every sprite name possible in states HashSet <string> stateSprites = new HashSet <string>(); foreach (State state in actor.actorStates.Values) { foreach (StateInfo stateInfo in state.info) { if (!stateSprites.Contains(stateInfo.spr)) { stateSprites.Add(stateInfo.spr); } } } // remember every sprite that matches a state sprite foreach (PICTURES sprite in allSprites.Values) { if (sprite.texture.name.Length < 4) { continue; } if (stateSprites.Contains(sprite.texture.name.Substring(0, 4))) { sprites.Add(sprite); } } }
private void Awake() { character = GetComponent <MonsterCharacter>(); thing = GetComponent <ThingController>(); character.OnInputRequest = FillInputFrame; }
public void addDeveloper (ThingController thing) { GameObject newDev = Instantiate (developer); newDev.transform.SetParent (transform, true); newDev.GetComponent<Developer> ().target = thing; }
// Use this for initialization void Start() { thingController = GetComponent <ThingController>(); textureAnimation = GetComponent <TextureAnimation>(); }
void AddThings() { thingParent = new GameObject("thingParent").transform; thingParent.parent = mapParent; foreach (THINGS thing in openedMap.things) { //Multiplayer only thing if (((thing.thingOptions & 0x10) >> 4) == 1) { continue; } float Zpos = 0; RaycastHit hit; //getting the Z(Y) height if (Physics.Raycast(new Vector3(thing.xPos, 5000, thing.yPos), Vector3.down, out hit, 10000, 1)) { Zpos = hit.point.y + 1; } Vector3 pos = new Vector3(thing.xPos, Zpos, thing.yPos); GameObject newThing = new GameObject(thing.thingType.ToString()); newThing.transform.parent = thingParent; newThing.transform.position = pos; if (MonsterType.ContainsKey(thing.thingType))//If its a monster { //Only spawn the monster if it is supposed to be on the current skill level if (skill == 0 || skill == 1) { if ((thing.thingOptions & 0x01) != 1) { continue; } else if (skill == 2) { if ((thing.thingOptions & 0x02) != 1) { continue; } else if (skill == 3 || skill == 4) { if ((thing.thingOptions & 0x04) != 1) { continue; } } } } newThing.AddComponent(MonsterType[thing.thingType]); newThing.AddComponent <Rigidbody>(); ThingController controller = newThing.AddComponent <ThingController>(); controller.OnCreate(reader.newWad.sprites, thing, reader.newWad.sounds); newThing.layer = 10; } else if (DecorationType.ContainsKey(thing.thingType))//if its a Decoration { newThing.AddComponent(DecorationType[thing.thingType]); ThingController controller = newThing.AddComponent <ThingController>(); controller.OnCreate(reader.newWad.sprites, thing, reader.newWad.sounds); } else if (PickupType.ContainsKey(thing.thingType))//if its a Pickup { newThing.AddComponent(PickupType[thing.thingType]); PickupController controller = newThing.AddComponent <PickupController>(); controller.OnCreate(reader.newWad.sprites, thing, reader.newWad.sounds); } else if (thing.thingType == 1)//player 1 { player.transform.position = pos; } } }
public void Damage(int amount, DamageType damageType = DamageType.Generic, GameObject attacker = null) { if (dead) { return; } if (CurrentBehavior != null) { CurrentBehavior.ModifyDamage(ref amount, damageType); } if (amount <= 0) { return; } hitpoints -= amount; if (hitpoints <= 0) { moveVector = Vector3.zero; gameObject.layer = 14; //ragdoll dead = true; if (DieFrames.Length > 0) { frametime = 0f; frameindex = 0; refreshSprite = true; SetSprite(DieFrames[0]); } if (DieSounds.Length > 0) { audioSource.Stop(); audioSource.clip = DieSounds[Random.Range(0, DieSounds.Length)]; audioSource.Play(); } //change type into decoration RemoveFromGrid(); thingType = ThingType.Decor; AddToGrid(); if (dropOnDeath != null) { ThingController loot = Instantiate(dropOnDeath); loot.transform.position = transform.position + transform.forward * .1f; loot.transform.rotation = transform.rotation; loot.Init(); loot.transform.SetParent(GameManager.Instance.TemporaryObjectsHolder); } return; } if (Random.value <= PainChance) { if (painTime < .1f) { if (PainSounds.Length > 0) { audioSource.Stop(); audioSource.clip = PainSounds[Random.Range(0, PainSounds.Length)]; audioSource.Play(); } } painTime = _PainTime; if (PainFrames.Length > 0) { frameindex = 0; frametime = 0f; refreshSprite = true; SetSprite(PainFrames[0]); } } CurrentBehavior.alert = true; //alert nearby enemies, since sound won't propagate here if (attacker != null) { if (attacker.GetComponent <PlayerThing>() != null) { if (GameManager.Instance.Player[0].playerBreath.GetBreath(cell) == null) { BreathArea alarmBreath = new BreathArea(15); alarmBreath.position = cell; List <ThingController> monsters = new List <ThingController>(); AI.FillBreath(ref alarmBreath, ref monsters, true); foreach (ThingController tc in monsters) { if (tc.CurrentBehavior != null) { tc.CurrentBehavior.AlertByNoise(); } } } } } }
public ThingState(ThingController controller) { this.controller = controller; Enter (); // Not nice having this here, but this is a throw-away state machine, so it's fine }
public DoneState(ThingController controller) : base(controller) { }
public NormalState(ThingController controller) : base(controller) { }
public static void UpdateWorldPosition() { InWorld = false; Rect screen = new Rect(0, 0, Screen.width, Screen.height); OnScreen = screen.Contains(Input.mousePosition); if (!OnScreen) { return; } Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit[] hits; hits = Physics.SphereCastAll(mouseRay, SelectionRadius, 300f, LayerMask.Shootables, QueryTriggerInteraction.Ignore); ThingController thing = null; float closest = float.MaxValue; Vector3 hitpoint = Vector3.zero; Vector3 hitnormal = Vector3.zero; foreach (RaycastHit hit in hits) { if (hit.collider.GetComponent <PlayerControls>() != null) { continue; } ThingController t = hit.collider.GetComponent <ThingController>(); if (t == null) { continue; } Vector3 origin = Camera.main.transform.position; float m = (hit.point - origin).sqrMagnitude; if (m < closest) { hitpoint = hit.point; hitnormal = hit.normal; closest = m; thing = t; } } if (Target != null) { if (Target != thing) { Target.OnMouseLeave.Invoke(); } } Target = thing; if (Target != null) { Target.OnMouseEnter.Invoke(); WorldPosition = hitpoint; InWorld = true; } else { //we didn't hit a thing, get point on virtual plane if (worldPlane.Raycast(mouseRay, out float distance)) { WorldPosition = mouseRay.origin + mouseRay.direction * distance; InWorld = true; } } if (InWorld) { GridPosition = TheGrid.GridPosition(WorldPosition); } }
void Start () { thing = GetComponentInParent<ThingController> (); thing.ProgressChanged += OnProgress; }