protected override bool Init() { // make sure fake classes aren't defined if (!VCPluginSettings.EzguiEnabled(gameObject)) return false; if (!base.Init ()) return false; if (colliderObject == movingPart) { // EZGUI hides controls by actually modifying their size and thusly their colliders, this will interfere // with collision detection behavior if the collider is on one of those objects. Debug.LogWarning("VCAnalogJoystickEzgui may not behave properly when the colliderObject is the same as the movingPart! " + "You should add a Collider to a gameObject independent from the EZGUI UI components."); } _movingPartBehaviorComponent = GetEzguiBehavior(movingPart); if (_movingPartBehaviorComponent == null) { VCUtils.DestroyWithError(gameObject, "Cannot find a SimpleSprite or UIButton component on movingPart. Destroying this control."); return false; } if (_collider == null) { VCUtils.DestroyWithError(gameObject, "No collider attached to colliderGameObject! Destroying this control."); return false; } return true; }
protected void AddBehaviour(UnityAction behaviour, UnityAction begin, UnityAction end) { ValidateBeginAndEndNames (behaviour, begin, end); string stateName = ValidateKey (behaviour.Method.Name); Behaviour b = new Behaviour (stateName, behaviour, begin, end); AddBehaviour (stateName, b); }
// Use this for initialization void Start() { col = GetComponent<BoxCollider2D>(); // 画像を切り替える component = componentHaveObject.GetComponent(type) as Behaviour; ChangeOnOffImage(); }
// Use this for initialization void Start () { //gameObject.GetComponent<Halo //Home = GameObject.FindGameObjectWithTag("TownHall"); halo = (Behaviour)GetComponent("Halo"); halo.enabled = false; CurTask = Task.None; }
// inser at begining fo the queue public void Insert(Behaviour behaviour, Observer observer) { if(observer != null){ behaviour.observer = observer; } behaviours.Push(behaviour); }
//forceful terminate a behaviour public void Terminate(Behaviour behaviour, TaskStatus result) { behaviour.status = result; if(behaviour.observer != null){ behaviour.observer(); } }
void Awake() { defaultMat = GetComponent<Renderer>().material; trail = GetComponent<TrailRenderer>(); trail.enabled = true; halo = (Behaviour)GetComponent("Halo"); }
public void Start() { // получаем компоненты у игрока и его характеристики PlCh = GameObject.Find("-Characteristics-").GetComponent<PlayerCharacteristics>(); myPathfinder = GetComponent<AIFollow>(); my = GetComponent<npcCharacteristics>(); myAnimator = myBody.GetComponent<Animator>(); myBehaviour = GetComponent<Behaviour>(); myEnemySearch = GetComponent<EnemySearchProtocol>(); aggressivePlayer = GetComponent<EnemyAttack>(); // Получаем контроллер _controller = GetComponent<CharacterController>(); // Получаем компонент трансформации объекта, к которому привязан данный компонент myTransform = transform; // Получаем компонент трансформации игрока myEnemyTransform = GameObject.Find("GLOBAL").transform; myModel = transform.GetChild(0); //выключаем пасфайндер, чтобы не ходил пока Walk(false); }
// Use this for initialization void Start() { m_Light = GetComponent<Light>(); m_Halo = (Behaviour) GetComponent("Halo"); EndFlash(); }
public MovePatrolVert( int upAmount, float speedMod) { goingUp = true; moveUp = new MoveUp(speedMod); moveDown = new MoveDown(speedMod); _upAmount = upAmount; _downAmount = 0; }
// Initialization void Start() { // Initialize halo halo = (Behaviour)light_source.GetComponent("Halo"); // Default light status to off light_source.light.enabled = false; halo.enabled = false; }
/// <summary> /// Picks the given action from the given agent. /// /// The method uses the agent's behaviour dictionary to get the /// action method. /// /// The log domain is set to "[AgentId].Action.[action_name]". /// /// The action name is set to "[BehaviourName].[action_name]". /// </summary> /// <param name="agent">The agent that can perform the action.</param> /// <param name="actionName">The name of the action</param> public POSHAction(Agent agent, string actionName) : base(string.Format("Action.{0}",actionName),agent) { behaviourDict = agent.getBehaviourDict(); action = behaviourDict.getAction(actionName); behaviour = behaviourDict.getActionBehaviour(actionName); name = string.Format("{0}.{1}",behaviour.GetName(),actionName); log.Debug("Created"); }
// Use this for initialization void Start() { halo = (Behaviour)gameObject.GetComponent("Halo"); if (tileType == TileType.empty) canPlace = true; else canPlace = false; UI = GameObject.Find("UI"); placementSelected = UI.GetComponent<_UI>().EggPlacement; }
/// <summary> /// Picks the given sense or sense-act from the given agent. /// /// The method uses the agent's behaviour dictionary to get the /// sense / sense-act method. /// /// The log domain is set to "[AgentId].Sense.[sense_name]". /// /// The sense name is set to "[BehaviourName].[sense_name]". /// </summary> /// <param name="agent">The agent that can use the sense.</param> /// <param name="senseName">The name of the sense</param> /// <param name="value">The value to compare it to. This is given as a string, /// but will be converted to an integer or float or boolean, or /// left as a string, whatever is possible. If None is given /// then the sense has to evaluate to True.</param> /// <param name="predicate">"==", "!=", "<", ">", "<=", ">=". If null is /// given, then "==" is assumed.</param> public POSHSense(Agent agent, string senseName, string value = null, string predicate = null) :base(string.Format("Sense.{0}",senseName),agent) { behaviourDict = agent.getBehaviourDict(); sense = behaviourDict.getSense(senseName); behaviour = behaviourDict.getSenseBehaviour(senseName); name = string.Format("{0}.{1}", behaviour.GetName(), senseName); this.value = (value is string) ? AgentInitParser.strToValue(value) : null; this.predicate = (predicate is string) ? predicate : "=="; log.Debug("Created"); }
void Start() { haloLoc=GameObject.Find("haloLoc"); if (haloLoc == null){Debug.Log("haloLoc not found");} if(haloLoc){ shineAround=(Behaviour)haloLoc.GetComponent("Halo"); if (shineAround == null){Debug.Log("halo effect not found");} if (shineAround){ shineAround.enabled=true ; } } }
private static void BuildBehaviours(BehaviourChain chain, Behaviour top) { var next = top; foreach (var node in chain) { if (node != chain.Top) { var inner = (Behaviour) IoC.Container.GetInstance(node.Type); next.Inner = inner; next = inner; } } }
// Use this for initialization void Start() { mat = GetComponent<Renderer>().material; light = GetComponent<Light>(); color_Mat = GetComponent<Renderer>().material.color; intensity = GetComponent<Light>().intensity; size_halo = 0.1f; halo = (Behaviour)GetComponent("Halo"); timer = 5; }
// Use this for initialization void Start () { this.GetComponent<GBScript>().goodorbad = 2; SoundVal = Random.Range (5, 10); //gameObject.GetComponent<Halo Home = GameObject.FindGameObjectWithTag("TownHall"); try { halo = (Behaviour)GetComponent("Halo"); halo.enabled = false; } catch { } CurTask = Task.Guard; }
/// <summary> /// Picks the given action from the given agent. /// /// The method uses the agent's behaviour dictionary to get the /// action method. /// /// The log domain is set to "[AgentId].Action.[action_name]". /// /// The action name is set to "[BehaviourName].[action_name]". /// </summary> /// <param name="agent">The agent that can perform the action.</param> /// <param name="actionName">The name of the action</param> public POSHAction(Agent agent, string actionName) : base(string.Format("Action.{0}",actionName),agent) { behaviourDict = agent.getBehaviourDict(); action = behaviourDict.getAction(actionName); behaviour = behaviourDict.getActionBehaviour(actionName); name = string.Format("{0}.{1}",behaviour.GetName(),actionName); log.Debug("Created"); //hook up to a listener for fire events if (agent.HasListenerForTyp(EventType.Fire)) agent.SubscribeToListeners(this, EventType.Fire); }
private static void PopulateBehaviours(BehaviourChain chain, Behaviour top) { var next = top; foreach (var node in chain) { if (node != chain.Top) { var inner = (Behaviour) Activator.CreateInstance(node.Type); next.Inner = inner; next = inner; } } }
public Enemy(Vector2 position, Wilderness wild, string name) { this.Position = position; this.Wilderness = wild; this.Name = name; this.Type = GameType.Enemy; this.mEngine = new AIEngine(this); this.currentBehaviour = Behaviour.None; this.IsAlive = true; random = new Random((int)(position.X + position.Y) - DateTime.Now.Millisecond); LoadContent(); mAnimator = new SuperNova.Graphics.Animator(mDie); this.LocalBounds = new Rectangle((int)Position.X, (int)Position.Y, 25, 25); }
// Use this for initialization void Start() { currentHP = maxHP; Color randColor = new Color(Random.value, Random.value, Random.value, 1.0f); GetComponent<SpriteRenderer>().color = randColor; maxHPBar = prefab.GetComponentInChildren<Slider>(); maxHPBar.maxValue = maxHP; maxHPBar.minValue = 0; badGuyAnimation = GetComponent<Animation>(); battle = GameObject.Find("ScriptManager").GetComponent<BattleStatePattern>(); halo = (Behaviour)GetComponent("Halo"); }
void Start() { nvs = GetComponent ("networkVariables") as networkVariables; myInfo = nvs.myInfo; ball = nvs.myInfo.ballGameObject; cart = nvs.myInfo.cartGameObject; //Create swing Icon for player swingIcon = Instantiate (Resources.Load ("swing_icon")) as GameObject; //Get glow effect on ball ballGlow = ball.GetComponent ("Halo") as Behaviour; ballGlow.enabled = false; attemptInitialize (); //for connecting swingIcon to the in level HUD }
static int _CreateBehaviour(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 0) { Behaviour obj = new Behaviour(); LuaScriptMgr.Push(L, obj); return 1; } else { LuaDLL.luaL_error(L, "invalid arguments to method: Behaviour.New"); } return 0; }
// Use this for initialization void Start() { _hasTarget = false; _aquireNewTarget = false; _target = null; _unitHalo = GetComponent("Halo") as Behaviour; _movementScript = this.GetComponent<MoveTowardsTarget>(); _unitsInRange = new List<GameObject>(); _anim = GetComponent<Animator>(); //_walkStateId = Animator.StringToHash("Base Layer.Walk"); _idleStateId = Animator.StringToHash("Base Layer.Idle"); _rotateStateId = Animator.StringToHash("Base Layer.Rotate"); }
protected override void showContextMenu(Behaviour behaviour) { CinemaActorClipCurve clipCurve = behaviour as CinemaActorClipCurve; if (clipCurve == null) return; List<KeyValuePair<string, string>> currentCurves = new List<KeyValuePair<string, string>>(); foreach (MemberClipCurveData data in clipCurve.CurveData) { KeyValuePair<string, string> curveStrings = new KeyValuePair<string, string>(data.Type, data.PropertyName); currentCurves.Add(curveStrings); } GenericMenu createMenu = new GenericMenu(); if (clipCurve.Actor != null) { Component[] components = DirectorHelper.getValidComponents(clipCurve.Actor.gameObject); for (int i = 0; i < components.Length; i++) { Component component = components[i]; MemberInfo[] members = DirectorHelper.getValidMembers(component); for (int j = 0; j < members.Length; j++) { AddCurveContext context = new AddCurveContext(); context.clipCurve = clipCurve; context.component = component; context.memberInfo = members[j]; if (!currentCurves.Contains(new KeyValuePair<string, string>(component.GetType().Name, members[j].Name))) { createMenu.AddItem(new GUIContent(string.Format("Add Curve/{0}/{1}", component.GetType().Name, DirectorHelper.GetUserFriendlyName(component, members[j]))), false, addCurve, context); } } } createMenu.AddSeparator(string.Empty); } createMenu.AddItem(new GUIContent("Copy"), false, copyItem, behaviour); createMenu.AddSeparator(string.Empty); createMenu.AddItem(new GUIContent("Clear"), false, deleteItem, clipCurve); createMenu.ShowAsContext(); }
// INIT // public void Initialize(Texture2D a_texture, Vector2 a_position) { tex = a_texture; position = a_position; speed = 1.5f; scale = 0.8f; // Change later if needed // width = tex.Width; height = tex.Height; boundingBox = new BoundingRect(position, Width, Height); dir = Direction.LEFT; behaviour = Behaviour.PATH; isAlive = true; attackPower = 1; }
protected override void showContextMenu(Behaviour behaviour) { CinemaShot shot = behaviour as CinemaShot; if (shot == null) return; Camera[] cameras = GameObject.FindObjectsOfType<Camera>(); GenericMenu createMenu = new GenericMenu(); createMenu.AddItem(new GUIContent("Focus"), false, focusShot, shot); foreach (Camera c in cameras) { ContextSetCamera arg = new ContextSetCamera(); arg.shot = shot; arg.camera = c; createMenu.AddItem(new GUIContent(string.Format(MODIFY_CAMERA, c.gameObject.name)), false, setCamera, arg); } createMenu.AddSeparator(string.Empty); createMenu.AddItem(new GUIContent("Copy"), false, copyItem, behaviour); createMenu.AddSeparator(string.Empty); createMenu.AddItem(new GUIContent("Clear"), false, deleteItem, shot); createMenu.ShowAsContext(); }
/// <summary> Manually searches through the parents for the required component. </summary> /// <typeparam name="T"> Type to find </typeparam> /// <returns> Found component, if any </returns> public static T GetComponentInParentInactive <T>(this Behaviour behaviour) where T : Component { return(GetComponentInParentInactive <T>(behaviour.gameObject)); }
/// <summary> /// Also merge user configs /// </summary> /// <param name="dispatcher"></param> /// <param name="containerFileName"></param> /// <param name="proj"></param> /// <param name="clonerBehaviour"></param> /// <param name="map"></param> /// <param name="configHash"></param> /// <returns></returns> private static MetadataContainer BuildMetadataWithSettings(IQueryDispatcher dispatcher, string containerFileName, ProjectContainer proj, Behaviour clonerBehaviour, Map map, string configHash) { var container = new MetadataContainer { ConfigFileHash = configHash, ServerMap = map.ConvertToDictionnary() }; ////Get servers source //var serversSource = map.Roads.Select(r => r.ServerSrc).Distinct().ToList(); ////Replace variables //for (int i = 0; i < serversSource.Count(); i++) //{ // if (serversSource[i].IsVariable()) // { // var configVar = map.Variables.FirstOrDefault(v => v.Name == serversSource[i]); // if (configVar == null) // throw new Exception($"The variable '{0}' is not found in the map with id='{1}'.", serversSource[i], map.Id)); // serversSource[i] = configVar.Value.ToString(); // } //} ////Copy connection strings //foreach (var cs in app.ConnectionStrings.Where(c => serversSource.Contains(c.Id.ToString()))) // container.ConnectionStrings.Add(new SqlConnection(cs.Id, cs.ProviderName, cs.ConnectionString)); //Copy connection strings foreach (var cs in proj.ConnectionStrings) { container.ConnectionStrings.Add( new SqlConnection(cs.Id) { ProviderName = cs.ProviderName, ConnectionString = cs.ConnectionString }); } if (container.ConnectionStrings.Count() == 0) { throw new Exception("No connectionStrings!"); } FetchMetadata(dispatcher, ref container); Behaviour behaviour = null; if (clonerBehaviour != null) { List <Variable> vars = null; if (map != null) { vars = map.Variables; } behaviour = clonerBehaviour.Build(proj.Templates, vars); } container.Metadatas.FinalizeMetadata(behaviour); return(container); }
public static void Disable(this Behaviour cmp) { cmp.enabled = false; }
/// <summary> /// Verify if the last build of the container's metadata still match with the current cloning settings. /// </summary> /// <param name="dispatcher">Query dispatcher</param> /// <param name="app">Application user config</param> /// <param name="mapId">MapId</param> /// <param name="behaviourId">BehaviourId</param> /// <param name="container">Container</param> public static void VerifyIntegrityWithSettings(IQueryDispatcher dispatcher, Settings settings, ref MetadataContainer container) { if (dispatcher == null) { throw new ArgumentNullException(nameof(dispatcher)); } if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (settings.Project == null) { throw new ArgumentNullException(nameof(settings.Project)); } if (String.IsNullOrWhiteSpace(settings.Project.Name)) { throw new ArgumentException(nameof(settings.Project.Name)); } if (settings.Project.ConnectionStrings != null && !settings.Project.ConnectionStrings.Any()) { throw new NullReferenceException("settings.Project.ConnectionStrings"); } var project = settings.Project; var containerFileName = project.Name + "_"; Map map = null; Behaviour clonerBehaviour = null; //Hash the selected map, connnectionStrings and the cloner //configuration to see if it match the lasted builded container var configData = new MemoryStream(); SerializationHelper.Serialize(configData, project.ConnectionStrings); if (settings.MapId.HasValue) { map = settings.Project.Maps.FirstOrDefault(m => m.Id == settings.MapId); if (map == null) { throw new Exception($"Map id '{settings.MapId}' not found in configuration file for application '{project.Name}'!"); } containerFileName += map.From + "-" + map.To; SerializationHelper.Serialize(configData, map); if (map.UsableBehaviours != null && map.UsableBehaviours.Split(',').ToList().Contains(settings.BehaviourId.ToString())) { clonerBehaviour = project.Behaviours.FirstOrDefault(c => c.Id == settings.BehaviourId); if (clonerBehaviour == null) { throw new KeyNotFoundException( $"There is no behaviour '{settings.BehaviourId}' in the configuration for the appName name '{project.Name}'."); } SerializationHelper.Serialize(configData, clonerBehaviour); SerializationHelper.Serialize(configData, project.Templates); } } else { containerFileName += "defaultMap"; } if (settings.BehaviourId != null) { containerFileName += "_" + settings.BehaviourId; } containerFileName += ".cache"; //Hash user config configData.Position = 0; //var murmur = MurmurHash.Create32(managed: false); //var configHash = Encoding.UTF8.GetString(murmur.ComputeHash(configData)); var configHash = container.ConfigFileHash + "random"; //If in-memory container is good, we use it if (container != null && container.ConfigFileHash == configHash) { return; } if (!settings.UseInMemoryCacheOnly) { //If container on disk is good, we use it container = TryLoadContainer(containerFileName, configHash); if (container != null) { dispatcher.InitProviders(container.Metadatas, container.ConnectionStrings); return; } } //We rebuild the container container = BuildMetadataWithSettings(dispatcher, containerFileName, project, clonerBehaviour, map, configHash); //Persist container if (!settings.UseInMemoryCacheOnly) { container.Save(containerFileName); } }
private bool CheckTile(TerrainType set, VirtualMap <char> mapData, int x, int y, Rectangle forceFill, Behaviour behaviour) { if (forceFill.Contains(x, y)) { return(true); } if (mapData == null) { return(behaviour.EdgesExtend); } if (x >= 0 && y >= 0 && x < mapData.Columns && y < mapData.Rows) { char c = mapData[x, y]; return(!IsEmpty(c) && !set.Ignore(c)); } if (!behaviour.EdgesExtend) { return(false); } char c2 = mapData[Util.Clamp(x, 0, mapData.Columns - 1), Util.Clamp(y, 0, mapData.Rows - 1)]; return(!IsEmpty(c2) && !set.Ignore(c2)); }
public override void OnStart() { GameObject target = GetTarget(this.m_Target); this.m_Component = target.GetComponent(this.m_ComponentName) as Behaviour; }
//private void SetAnimatorInteger(string triggerName, int intVal) //{ // if (animator != null) // { // animator.SetInteger(triggerName, intVal); // } //} //private static Vector3 GetRandomPosition(Vector3 origin, float distance, int layermask) //{ // Vector3 randomDirection = UnityEngine.Random.insideUnitSphere * distance; // randomDirection += origin; // NavMeshHit navHit; // NavMesh.SamplePosition(randomDirection, out navHit, distance, layermask); // return navHit.position; //} //private void CountDownForWander() //{ // //StopWander(); // CancelInvoke("CountDownForWander"); //} private void SetCurrentBehaviour(Behaviour behaviour) { currentBehaviour = behaviour; }
/// <summary> /// Removes a behaviour of the list of behaviours to toggle when <see cref="loadedSetup"/> changes. /// </summary> /// <param name="behaviour">The behaviour to remove.</param> public void RemoveBehaviourToToggleOnLoadedSetupChange(Behaviour behaviour) { _behavioursToToggleOnLoadedSetupChange.Remove(behaviour); }
private void ParseAt(DataStructures.GameData.GameData gd, IEnumerator <LexObject> iterator) { iterator.MoveNext(); var type = iterator.Current.Value; if (type.Equals("include", StringComparison.OrdinalIgnoreCase)) { Expect(iterator, LexType.String); if (CurrentFile != null) { var filename = iterator.Current.GetValue(); var path = Path.GetDirectoryName(CurrentFile) ?? ""; var incfile = Path.Combine(path, filename); var current = CurrentFile; var incgd = GetGameDataFromFile(incfile); CurrentFile = current; if (!gd.Includes.Any(x => String.Equals(x, filename, StringComparison.OrdinalIgnoreCase))) { gd.Includes.Add(filename); } // Merge the included gamedata into the current one gd.MapSizeHigh = Math.Max(incgd.MapSizeHigh, gd.MapSizeHigh); gd.MapSizeLow = Math.Min(incgd.MapSizeLow, gd.MapSizeLow); gd.Includes.AddRange(incgd.Includes.Where(x => !gd.Includes.Contains(x))); gd.Classes.AddRange(incgd.Classes.Where(x => !gd.Classes.Any(y => String.Equals(x.Name, y.Name, StringComparison.OrdinalIgnoreCase)))); gd.AutoVisgroups.AddRange(incgd.AutoVisgroups.Where(x => !gd.AutoVisgroups.Any(y => String.Equals(x.Name, y.Name, StringComparison.OrdinalIgnoreCase)))); gd.MaterialExclusions.AddRange(incgd.MaterialExclusions.Where(x => !gd.MaterialExclusions.Any(y => String.Equals(x, y, StringComparison.OrdinalIgnoreCase)))); } else { throw new ProviderException("Unable to include a file when not reading from a file."); } } else if (type.Equals("mapsize", StringComparison.OrdinalIgnoreCase)) { Expect(iterator, LexType.OpenParen); Expect(iterator, LexType.Value); gd.MapSizeLow = Int32.Parse(iterator.Current.Value); Expect(iterator, LexType.Comma); Expect(iterator, LexType.Value); gd.MapSizeHigh = Int32.Parse(iterator.Current.Value); Expect(iterator, LexType.CloseParen); } else if (type.Equals("materialexclusion", StringComparison.OrdinalIgnoreCase)) { Expect(iterator, LexType.OpenBracket); iterator.MoveNext(); while (iterator.Current.Type != LexType.CloseBracket) { Assert(iterator.Current, iterator.Current.IsValueOrString(), "Expected value type, got " + iterator.Current.Type + "."); var exclusion = iterator.Current.GetValue(); gd.MaterialExclusions.Add(exclusion); iterator.MoveNext(); } } else if (type.Equals("autovisgroup", StringComparison.OrdinalIgnoreCase)) { Expect(iterator, LexType.Equals); iterator.MoveNext(); Assert(iterator.Current, iterator.Current.IsValueOrString(), "Expected value type, got " + iterator.Current.Type + "."); var sectionName = iterator.Current.GetValue(); var sect = new AutoVisgroupSection { Name = sectionName }; Expect(iterator, LexType.OpenBracket); iterator.MoveNext(); while (iterator.Current.Type != LexType.CloseBracket) { Assert(iterator.Current, iterator.Current.IsValueOrString(), "Expected value type, got " + iterator.Current.Type + "."); var groupName = iterator.Current.GetValue(); var grp = new AutoVisgroup { Name = groupName }; Expect(iterator, LexType.OpenBracket); iterator.MoveNext(); while (iterator.Current.Type != LexType.CloseBracket) { Assert(iterator.Current, iterator.Current.IsValueOrString(), "Expected value type, got " + iterator.Current.Type + "."); var entity = iterator.Current.GetValue(); grp.EntityNames.Add(entity); iterator.MoveNext(); } sect.Groups.Add(grp); } gd.AutoVisgroups.Add(sect); } else { // Parsing: // @TypeClass name(param, param) name() var ct = ParseClassType(type, iterator.Current); var gdo = new GameDataObject("", "", ct); iterator.MoveNext(); while (iterator.Current.Type == LexType.Value) { // Parsing: // @TypeClass {name(param, param) name()} var name = iterator.Current.Value; var bh = new Behaviour(name); iterator.MoveNext(); if (iterator.Current.Type == LexType.Value) { // Allow for the following (first seen in hl2 base): // @PointClass {halfgridsnap} base(Targetname) continue; } Assert(iterator.Current, iterator.Current.Type == LexType.OpenParen, "Unexpected " + iterator.Current.Type); iterator.MoveNext(); while (iterator.Current.Type != LexType.CloseParen) { // Parsing: // name({param, param}) if (iterator.Current.Type != LexType.Comma) { Assert(iterator.Current, iterator.Current.Type == LexType.Value || iterator.Current.Type == LexType.String, "Unexpected " + iterator.Current.Type + "."); var value = iterator.Current.Value; if (iterator.Current.Type == LexType.String) { value = value.Trim('"'); } bh.Values.Add(value); } iterator.MoveNext(); } Assert(iterator.Current, iterator.Current.Type == LexType.CloseParen, "Unexpected " + iterator.Current.Type); // Treat base behaviour as a special case if (bh.Name == "base") { gdo.BaseClasses.AddRange(bh.Values); } else { gdo.Behaviours.Add(bh); } iterator.MoveNext(); } // = class_name : "Descr" + "iption" [ Assert(iterator.Current, iterator.Current.Type == LexType.Equals, "Expected equals, got " + iterator.Current.Type); Expect(iterator, LexType.Value); gdo.Name = iterator.Current.Value; iterator.MoveNext(); if (iterator.Current.Type == LexType.Colon) { // Parsing: // : {"Descr" + "iption"} [ iterator.MoveNext(); gdo.Description = ParsePlusString(iterator); } Assert(iterator.Current, iterator.Current.Type == LexType.OpenBracket, "Unexpected " + iterator.Current.Type); // Parsing: // name(type) : "Desc" : "Default" : "Long Desc" = [ ... ] // input name(type) : "Description" // output name(type) : "Description" iterator.MoveNext(); while (iterator.Current.Type != LexType.CloseBracket) { Assert(iterator.Current, iterator.Current.Type == LexType.Value, "Unexpected " + iterator.Current.Type); var pt = iterator.Current.Value; if (pt == "input" || pt == "output") // IO { // input name(type) : "Description" var io = new IO(); Expect(iterator, LexType.Value); io.IOType = (IOType)Enum.Parse(typeof(IOType), pt, true); io.Name = iterator.Current.Value; Expect(iterator, LexType.OpenParen); Expect(iterator, LexType.Value); io.VariableType = ParseVariableType(iterator.Current); Expect(iterator, LexType.CloseParen); iterator.MoveNext(); // if not colon, this will be the value of the next io/property, or close if (iterator.Current.Type == LexType.Colon) { iterator.MoveNext(); io.Description = ParsePlusString(iterator); } gdo.InOuts.Add(io); } else // Property { Expect(iterator, LexType.OpenParen); Expect(iterator, LexType.Value); var vartype = ParseVariableType(iterator.Current); Expect(iterator, LexType.CloseParen); var prop = new Property(pt, vartype); iterator.MoveNext(); // if not colon or equals, this will be the value of the next io/property, or close if (iterator.Current.Type == LexType.Value) { // Check for additional flags on the property // e.g.: name(type) readonly : "This is a read only value" // name(type) report : "This value will show in the entity report" switch (iterator.Current.Value) { case "readonly": prop.ReadOnly = true; iterator.MoveNext(); break; case "report": prop.ShowInEntityReport = true; iterator.MoveNext(); break; } } do // Using do/while(false) so I can break out - reduces nesting. { // Short description if (iterator.Current.Type != LexType.Colon) { break; } iterator.MoveNext(); prop.ShortDescription = ParsePlusString(iterator); // Default value if (iterator.Current.Type != LexType.Colon) { break; } iterator.MoveNext(); if (iterator.Current.Type != LexType.Colon) // Allow for ': :' structure (no default) { if (iterator.Current.Type == LexType.String) { prop.DefaultValue = iterator.Current.Value.Trim('"'); } else { Assert(iterator.Current, iterator.Current.Type == LexType.Value, "Unexpected " + iterator.Current.Type); prop.DefaultValue = iterator.Current.Value; } iterator.MoveNext(); } // Long description if (iterator.Current.Type != LexType.Colon) { break; } iterator.MoveNext(); prop.Description = ParsePlusString(iterator); } while (false); if (iterator.Current.Type == LexType.Equals) { Expect(iterator, LexType.OpenBracket); // Parsing property options: // value : description // value : description : 0 iterator.MoveNext(); while (iterator.Current.IsValueOrString()) { var opt = new Option { Key = iterator.Current.GetValue() }; Expect(iterator, LexType.Colon); // Some FGDs use values for property descriptions instead of strings iterator.MoveNext(); Assert(iterator.Current, iterator.Current.IsValueOrString(), "Choices value must be value or string type."); if (iterator.Current.Type == LexType.String) { opt.Description = ParsePlusString(iterator); } else { opt.Description = iterator.Current.GetValue(); iterator.MoveNext(); // ParsePlusString moves next once it's complete, need to do the same here } prop.Options.Add(opt); if (iterator.Current.Type != LexType.Colon) { continue; } Expect(iterator, LexType.Value); opt.On = iterator.Current.Value == "1"; iterator.MoveNext(); } Assert(iterator.Current, iterator.Current.Type == LexType.CloseBracket, "Unexpected " + iterator.Current.Type); iterator.MoveNext(); } gdo.Properties.Add(prop); } } Assert(iterator.Current, iterator.Current.Type == LexType.CloseBracket, "Unexpected " + iterator.Current.Type); gd.Classes.Add(gdo); } }
// Use this for initialization void Start() { b = (Behaviour)GetComponent("Halo"); r = GetComponent <MeshRenderer>(); }
public void RemoveBehaviour(Behaviour item) { _behaviourManager.RemoveBehaviour(item); }
private char GetTile(VirtualMap <char> mapData, int x, int y, Rectangle forceFill, char forceID, Behaviour behaviour) { if (forceFill.Contains(x, y)) { return(forceID); } if (mapData == null) { if (!behaviour.EdgesExtend) { return('0'); } return(forceID); } else { if (x >= 0 && y >= 0 && x < mapData.Columns && y < mapData.Rows) { return(mapData[x, y]); } if (!behaviour.EdgesExtend) { return('0'); } int x2 = Util.Clamp(x, 0, mapData.Columns - 1); int y2 = Util.Clamp(y, 0, mapData.Rows - 1); return(mapData[x2, y2]); } }
public void AddBehaviour(Behaviour item) { _behaviourManager.AddBehaviour(item); }
public TrackItemEventArgs(Behaviour item, float firetime) { this.item = item; this.firetime = firetime; }
/// <summary> /// Links the given MonoBehaviour script to the provided state type. /// </summary> /// <typeparam name="T">The type of state with which to link the <see cref="Behaviour"/>.</typeparam> /// <param name="behaviour">The MonoBehaviour to link.</param> /// <param name="enabledByDefault">If true, this object will be enabled when its scene becomes active.</param> /// <param name="useStrictLinking">When true, this Behaviour will be disabled when a new <see cref="State"/> /// is pushed before its parent <see cref="State"/> is popped.</param> public void Link <T>(Behaviour behaviour, bool enabledByDefault = true, bool useStrictLinking = true) where T : State { stateBehaviours.Link <T>(behaviour, CurrentState is T, enabledByDefault, useStrictLinking); }
private TileGrid Generate(VirtualMap <char> mapData, int startX, int startY, int tilesX, int tilesY, int forceSolid, char forceID, Behaviour behaviour) { TileGrid tileGrid = new TileGrid(8, 8, tilesX, tilesY); Rectangle empty = Rectangle.Empty; if (forceSolid != 0) { empty = new Rectangle(startX, startY, tilesX, tilesY); } if (mapData != null) { for (int i = startX; i < startX + tilesX; i += 50) { for (int j = startY; j < startY + tilesY; j += 50) { if (!mapData.AnyInSegmentAtTile(i, j)) { j = j / 50 * 50; } else { int k = i; int num = Math.Min(i + 50, startX + tilesX); while (k < num) { int l = j; int num2 = Math.Min(j + 50, startY + tilesY); while (l < num2) { Tiles tiles = TileHandler(mapData, k, l, forceSolid, empty, forceID, behaviour); if (tiles != null) { tileGrid.Tiles[k - startX, l - startY] = Util.Random.Choose(tiles.Textures); } l++; } k++; } } } } } else { for (int m = startX; m < startX + tilesX; m++) { for (int n = startY; n < startY + tilesY; n++) { Tiles tiles2 = TileHandler(null, m, n, forceSolid, empty, forceID, behaviour); if (tiles2 != null) { tileGrid.Tiles[m - startX, n - startY] = Util.Random.Choose(tiles2.Textures); } } } } return(tileGrid); }
public static bool IsActive(Behaviour mb) { return(mb != null && mb.enabled && mb.gameObject.activeInHierarchy); }
public static Services.Coroutine CoroutineStart(this Behaviour behaviour, IEnumerator routine, bool alwaysActive = true) { return(ServiceCache.Coroutine.StartCoroutine(new BehaviourLinkHandler(behaviour, alwaysActive), routine)); }
void SetHalo(bool b) { Behaviour halo = (Behaviour)GetComponent("Halo"); halo.enabled = b; }
private Tiles TileHandler(VirtualMap <char> mapData, int x, int y, int forceSolid, Rectangle forceFill, char forceID, Behaviour behaviour) { char tile = GetTile(mapData, x, y, forceFill, forceID, behaviour); if (IsEmpty(tile)) { return(null); } TerrainType terrainType = lookup[tile]; if (forceSolid == 1 && mapData == null) { return(terrainType.Center); } bool flag = true; int num = 0; for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { bool flag2 = CheckTile(terrainType, mapData, x + j, y + i, forceFill, behaviour); if (!flag2 && behaviour.EdgesIgnoreOutOfLevel && !CheckForSameLevel(x, y, x + j, y + i)) { flag2 = true; } adjacent[num++] = (flag2 ? (byte)1 : (byte)0); if (!flag2) { flag = false; } } } if (!flag) { foreach (Masked masked in terrainType.Masked) { bool flag3 = true; int num2 = 0; while (num2 < 9 && flag3) { if (masked.Mask[num2] != 2 && masked.Mask[num2] != adjacent[num2]) { flag3 = false; } num2++; } if (flag3) { return(masked.Tiles); } } return(null); } bool flag4; if (!behaviour.PaddingIgnoreOutOfLevel) { flag4 = (!CheckTile(terrainType, mapData, x - 2, y, forceFill, behaviour) || !CheckTile(terrainType, mapData, x + 2, y, forceFill, behaviour) || !CheckTile(terrainType, mapData, x, y - 2, forceFill, behaviour) || !CheckTile(terrainType, mapData, x, y + 2, forceFill, behaviour)); } else { flag4 = ((!CheckTile(terrainType, mapData, x - 2, y, forceFill, behaviour) && CheckForSameLevel(x, y, x - 2, y)) || (!CheckTile(terrainType, mapData, x + 2, y, forceFill, behaviour) && CheckForSameLevel(x, y, x + 2, y)) || (!CheckTile(terrainType, mapData, x, y - 2, forceFill, behaviour) && CheckForSameLevel(x, y, x, y - 2)) || (!CheckTile(terrainType, mapData, x, y + 2, forceFill, behaviour) && CheckForSameLevel(x, y, x, y + 2))); } if (flag4) { return(terrainType.Padded); } return(terrainType.Center); }
public static bool IsTrackItemValidForTrack(Behaviour behaviour, TimelineTrack track) { bool retVal = false; if (track.GetType()==(typeof(ShotTrack))) { if (behaviour.GetType() == (typeof(CinemaShot))) { retVal = true; } } else if (track.GetType()==(typeof(AudioTrack))) { if (behaviour.GetType() == (typeof(CinemaAudio))) { retVal = true; } } else if (track.GetType()==(typeof(GlobalItemTrack)) || track.GetType().IsSubclassOf(typeof(GlobalItemTrack))) { if (behaviour.GetType() == typeof(CinemaShot) || (behaviour.GetType().IsSubclassOf(typeof(CinemaAudio)))) { retVal = false; } else if (behaviour.GetType().IsSubclassOf(typeof(CinemaGlobalAction)) || behaviour.GetType().IsSubclassOf(typeof(CinemaGlobalEvent))) { retVal = true; } } else if (track.GetType()==(typeof(ActorItemTrack)) || track.GetType().IsSubclassOf(typeof(ActorItemTrack))) { if (behaviour.GetType().IsSubclassOf(typeof(CinemaActorAction)) || behaviour.GetType().IsSubclassOf(typeof(CinemaActorEvent))) { retVal = true; } } else if (track.GetType() == (typeof(CurveTrack)) || track.GetType().IsSubclassOf(typeof(CurveTrack))) { if (behaviour.GetType()==(typeof(CinemaActorClipCurve))) { retVal = true; } } else if (track.GetType() == (typeof(MultiCurveTrack)) || track.GetType().IsSubclassOf(typeof(MultiCurveTrack))) { if (behaviour.GetType()==(typeof(CinemaMultiActorCurveClip))) { retVal = true; } } return retVal; }
private Camera CreateEye(Camera camera, string gameObjectName, float yRot, float xOffset, int cameraTargetHeight, int cullingMask, float fov, float aspect, int aalevel) { bool isCreated = false; if (camera == null) { GameObject eye = new GameObject(gameObjectName); eye.transform.parent = _cameraGroup; eye.transform.rotation = Quaternion.AngleAxis(-yRot, Vector3.right); eye.transform.localPosition = new Vector3(xOffset, 0f, 0f); camera = eye.AddComponent <Camera>(); isCreated = true; } camera.fieldOfView = fov; camera.aspect = aspect; camera.clearFlags = _settings.cameraClearMode; camera.backgroundColor = _settings.cameraClearColor; camera.cullingMask = cullingMask; camera.useOcclusionCulling = _settings.camera.useOcclusionCulling; camera.renderingPath = _settings.camera.renderingPath; #if UNITY_5_6_OR_NEWER camera.allowHDR = _settings.camera.allowHDR; camera.allowMSAA = _settings.camera.allowMSAA; if (camera.renderingPath == RenderingPath.DeferredShading #if AVPRO_MOVIECAPTURE_DEFERREDSHADING || camera.renderingPath == RenderingPath.DeferredLighting #endif ) { camera.allowMSAA = false; } #endif { int textureWidth = _settings.pixelSliceSize + 2 * _settings.paddingSize; int textureHeight = cameraTargetHeight; if (camera.targetTexture != null) { camera.targetTexture.DiscardContents(); if (camera.targetTexture.width != textureWidth || camera.targetTexture.height != textureHeight || camera.targetTexture.antiAliasing != aalevel) { RenderTexture.ReleaseTemporary(camera.targetTexture); camera.targetTexture = null; } } if (camera.targetTexture == null) { camera.targetTexture = RenderTexture.GetTemporary(textureWidth, textureHeight, 24, RenderTextureFormat.Default, RenderTextureReadWrite.Default, aalevel); } } camera.enabled = false; // TODO: make it so the components can be added/updated each time if they have changed if (isCreated) { if (_settings.cameraImageEffects != null) { for (int i = 0; i < _settings.cameraImageEffects.Length; i++) { Behaviour origComponent = _settings.cameraImageEffects[i]; if (origComponent != null) { if (origComponent.enabled) { #if UNITY_EDITOR Component newComponent = camera.gameObject.AddComponent(origComponent.GetType()); // TODO: we need to copy any post image effect component fields here via reflection? or perhaps use prefabs? UnityEditor.EditorUtility.CopySerialized(origComponent, newComponent); #endif } } else { Debug.LogWarning("[AVProMovieCapture] Image effect is null"); } } } } return(camera); }
public bool CheckRangeCategoryOnAttack(ProjetPirate.Boat.BoatCharacter pPotentialTarget) { float distance = Vector3.Distance(this.transform.position, pPotentialTarget.transform.position); for (int i = 0; i < _onAttackRangeCategories.Count; i++) { if (_onAttackRangeCategories[i].RangeRatio * _defaultRange >= distance | _onAttackRangeCategories[i].RangeRatio == 0) { switch (_onAttackRangeCategories[i].Type) { case AggroRequiredType.XP_More: switch (pPotentialTarget.ShipType) { case Boat.ShipType.Player_Level_1: case Boat.ShipType.Player_Level_2: case Boat.ShipType.Player_Level_3: if (pPotentialTarget.Controller.GetComponent <Player>()._data.Ressource.Reputation >= _onAttackRangeCategories[i].Quantity) { _behaviour = _onAttackRangeCategories[i].AssociatedBehaviour; return(true); } break; default: break; } break; case AggroRequiredType.XP_Less: switch (pPotentialTarget.ShipType) { case Boat.ShipType.Player_Level_1: case Boat.ShipType.Player_Level_2: case Boat.ShipType.Player_Level_3: if (pPotentialTarget.Controller.GetComponent <Player>()._data.Ressource.Reputation <= _onDetectionRangeCategories[i].Quantity) { Debug.Log(i); _behaviour = _onDetectionRangeCategories[i].AssociatedBehaviour; return(true); } break; default: break; } break; case AggroRequiredType.BoatLevel_Less: switch (pPotentialTarget.ShipType) { case Boat.ShipType.Player_Level_1: if (_onAttackRangeCategories[i].Quantity <= 1) { _behaviour = _onAttackRangeCategories[i].AssociatedBehaviour; return(true); } break; case Boat.ShipType.Player_Level_2: if (_onAttackRangeCategories[i].Quantity <= 2) { _behaviour = _onAttackRangeCategories[i].AssociatedBehaviour; return(true); } break; case Boat.ShipType.Player_Level_3: if (_onAttackRangeCategories[i].Quantity <= 3) { _behaviour = _onAttackRangeCategories[i].AssociatedBehaviour; return(true); } break; default: break; } break; case AggroRequiredType.BoatLevel_More: switch (pPotentialTarget.ShipType) { case Boat.ShipType.Player_Level_1: if (_onAttackRangeCategories[i].Quantity >= 1) { _behaviour = _onAttackRangeCategories[i].AssociatedBehaviour; return(true); } break; case Boat.ShipType.Player_Level_2: if (_onAttackRangeCategories[i].Quantity >= 2) { _behaviour = _onAttackRangeCategories[i].AssociatedBehaviour; return(true); } break; case Boat.ShipType.Player_Level_3: if (_onAttackRangeCategories[i].Quantity >= 3) { _behaviour = _onAttackRangeCategories[i].AssociatedBehaviour; return(true); } break; default: break; } break; case AggroRequiredType.None: _behaviour = _onAttackRangeCategories[i].AssociatedBehaviour; return(true); case AggroRequiredType.Life_More: if (pPotentialTarget.getCurrentLife() > _onAttackRangeCategories[i].Quantity) { _behaviour = _onAttackRangeCategories[i].AssociatedBehaviour; } break; case AggroRequiredType.Life_Less: if (pPotentialTarget.getCurrentLife() < _onAttackRangeCategories[i].Quantity) { _behaviour = _onAttackRangeCategories[i].AssociatedBehaviour; } break; default: break; } } } return(false); }
//-------------------------------------------------------------------------------------------------------------------------- public static void ToggleEnabled(this Behaviour cmp) { cmp.enabled = !cmp.enabled; }
// Use this for initialization void Awake() { halob = GetComponent ("Halo") as Behaviour; }
public static void Enable(this Behaviour cmp) { cmp.enabled = true; }
void OnMouseOver() { Behaviour halo = (Behaviour)gameObject.GetComponent("Halo"); halo.enabled = true; }
public void SetGameState(RoomFriendStatus net) { this.FriendStatus = net; this._ladderlockFlag = false; if (net == RoomFriendStatus.Offline) { Behaviour arg_2D_0 = this.F_OfflineSign; bool flag = false; this.F_OnlineSign.enabled = flag; arg_2D_0.enabled = !flag; this.F_Type.color = Color.gray; this.SetInvitationBtnState(2); this.F_Type.text = LanguageManager.Instance.GetStringById("FriendsUI_FriendState_Offline"); this.F_Invitation.text = string.Empty; base.transform.FindChild("RaidLevelLimit").gameObject.SetActive(false); } else if (net == RoomFriendStatus.Online) { Behaviour arg_B1_0 = this.F_OfflineSign; bool flag = true; this.F_OnlineSign.enabled = flag; arg_B1_0.enabled = !flag; this.F_Type.color = Color.green; this.F_Type.text = LanguageManager.Instance.GetStringById("FriendsUI_FriendState_Online"); int scene_limit_level = BaseDataMgr.instance.GetDataById <SysBattleSceneVo>("80006").scene_limit_level; if (Singleton <PvpRoomView> .Instance.battleId == "80006" && int.Parse(this.F_GradeNumber.text) < scene_limit_level) { this._ladderlockFlag = true; base.transform.FindChild("RaidLevelLimit").gameObject.SetActive(true); this.SetInvitationBtnState(2); } else { base.transform.FindChild("RaidLevelLimit").gameObject.SetActive(false); this.SetInvitationBtnState(1); } } else if (net == RoomFriendStatus.Playing) { Behaviour arg_198_0 = this.F_OfflineSign; bool flag = true; this.F_OnlineSign.enabled = flag; arg_198_0.enabled = !flag; this.SetInvitationBtnState(2); this.F_Type.color = Color.yellow; this.F_Type.text = LanguageManager.Instance.GetStringById("FriendsUI_FriendState_Busyness"); this.F_Invitation.text = string.Empty; base.transform.FindChild("RaidLevelLimit").gameObject.SetActive(false); } else if (net == RoomFriendStatus.Refuse) { Behaviour arg_21D_0 = this.F_OfflineSign; bool flag = true; this.F_OnlineSign.enabled = flag; arg_21D_0.enabled = !flag; this.SetInvitationBtnState(2); this.F_Invitation.text = LanguageManager.Instance.GetStringById("GangUpUI_Decline"); this.F_Invitation.color = Color.red; base.transform.FindChild("RaidLevelLimit").gameObject.SetActive(false); } else { Behaviour arg_28B_0 = this.F_OfflineSign; bool flag = true; this.F_OnlineSign.enabled = flag; arg_28B_0.enabled = !flag; this.SetInvitationBtnState(2); this.F_Type.color = Color.green; this.F_Type.text = LanguageManager.Instance.GetStringById("FriendsUI_FriendState_Room"); this.F_Invitation.text = string.Empty; base.transform.FindChild("RaidLevelLimit").gameObject.SetActive(false); } }
void OnMouseExit() { Behaviour halo = (Behaviour)gameObject.GetComponent("Halo"); halo.enabled = false; }
void Start() { Behaviour halo = (Behaviour)gameObject.GetComponent("Halo"); halo.enabled = false; }
//public AudioClip piece; private void DoActivateTrigger() { triggerCount--; if (triggerCount == 0 || repeatTrigger) { Object currentTarget = target ?? gameObject; Behaviour targetBehaviour = currentTarget as Behaviour; GameObject targetGameObject = currentTarget as GameObject; if (targetBehaviour != null) { targetGameObject = targetBehaviour.gameObject; } switch (action) { case Mode.Trigger: if (targetGameObject != null) { targetGameObject.BroadcastMessage("DoActivateTrigger"); } break; case Mode.Replace: if (source != null) { if (targetGameObject != null) { Instantiate(source, targetGameObject.transform.position, targetGameObject.transform.rotation); DestroyObject(targetGameObject); } } break; case Mode.Activate: if (targetGameObject != null) { targetGameObject.SetActive(true); } break; case Mode.Enable: if (targetBehaviour != null) { targetBehaviour.enabled = true; } break; case Mode.Animate: if (targetGameObject != null) { targetGameObject.GetComponent <Animation>().Play(); } break; case Mode.Deactivate: if (targetGameObject != null) { targetGameObject.SetActive(false); } break; case Mode.PlayMusic: if (targetGameObject != null) { targetGameObject.GetComponent <AudioSource>().PlayOneShot(targetGameObject.GetComponent <AudioSource>().clip, 0.7f); } break; } } }
public static bool GetActive(Behaviour mb) { return((bool)mb && mb.enabled && mb.gameObject.activeInHierarchy); }