Example #1
0
 void hide(GameObject bt)
 {
     messageBox.gameObject.SetActive(false);
     blurPanel.gameObject.SetActive(false);
     info.show = false;
     isShow = false;
 }
Example #2
0
 public ISWeapon(int durability, int maxDurability, ISEquipmentSlot equipmentSlot, GameObject prefab)
 {
     _durability = durability;
     _maxDurability = maxDurability;
     _equipmentSlot = equipmentSlot;
     _prefab = prefab;
 }
        public void SubmitLap(GameObject car, int team)
        {
            switch (team)
            {
                case 1:
                    if (m_LapTimeTeamOne >= 60.0f)
                    {
                        m_LapsTeamOne += 1;
                        m_LapTimeTeamOne = 0.0f;
                    }
                    break;

                case 2:
                    if (m_LapTimeTeamTwo >= 60.0f)
                    {
                        m_LapsTeamTwo += 1;
                        m_LapTimeTeamTwo = 0.0f;
                    }
                    break;
            }

            if (m_LapsTeamOne >= 2)
            {
                instance.SubmitGameResults(m_TeamOneWon);
            }
            if (m_LapsTeamTwo >= 2)
            {
                instance.SubmitGameResults(m_TeamTwoWon);
            }
        }
Example #4
0
				//private PlayerScript controller;
		
				public PlayState2 (StateManager managerRef)
				{ //Constructor
						manager = managerRef;
						Debug.Log ("Constructing PlayState2");
						manager.darkState = false; 
			
						"Stage2".LoadScene ();
						//if (Application.loadedLevelName != "Stage2")
						//		Application.LoadLevel ("Stage2");
			
						StaticMethods.SetOneActive ("Following Camera", manager.gameDataRef.cameras); //Camera that follows the Player, setOneActive method

						player = GameObject.FindGameObjectWithTag ("Player"); //the Player GameObject is now active and can be found
						player.GetComponent<Rigidbody2D> ().isKinematic = false; //Player is now affected by physics
			
						player.transform.SetPositionXY (-6.0f, -0.4f); //set starting position for Player
						skin = Resources.Load ("GUISkin") as GUISkin;
				
						//darkness = GameObject.FindGameObjectWithTag ("Darkness");
						//dark.a += 0f;
						//darkness.GetComponent<Renderer>().material.color = dark; 
			
						//darkness.GetComponent<Renderer>().material.color.a;
						//Color dark = darkness.renderer.material.color;
						//dark.a -= 0;
						//darkness.renderer.material.color = color;
				}
        public override void UpdateTime(GameObject Actor, float runningTime, float deltaTime)
        {
            Animation animation = Actor.GetComponent<Animation>();

            if (!animation || animationClip == null)
            {
                return;
            }

            if (animation[animationClip.name] == null)
            {
                animation.AddClip(animationClip, animationClip.name);
            }

            AnimationState state = animation[animationClip.name];

            if (!animation.IsPlaying(animationClip.name))
            {
                animation.wrapMode = wrapMode;
                animation.Play(animationClip.name);
            }

            state.time = runningTime;
            state.enabled = true;
            animation.Sample();
            state.enabled = false;
        }
 public static void CreatePulse(MenuCommand menuCommand)
 {
     var pulse = new GameObject("Pulse", typeof(Pulse));
     GameObjectUtility.SetParentAndAlign(pulse, menuCommand.context as GameObject);
     Undo.RegisterCreatedObjectUndo(pulse, "Create " + pulse.name);
     Selection.activeGameObject = pulse;
 }
Example #7
0
		void DoAddComponent(GameObject go)
		{
			addedComponent = go.AddComponent(script.Value);

			if (addedComponent == null)
				ActionHelpers.RuntimeError(this, "Can't add script: " + script.Value);
		}
		void SetTag(GameObject parent)
		{
			if (parent == null)
			{
				return;
			}

            if (string.IsNullOrEmpty(filterByComponent.Value)) // do all children
            {
                foreach (Transform child in parent.transform)
                {
                    child.gameObject.tag = tag.Value;
                }
            }
            else
            {
                UpdateComponentFilter();

                if (componentFilter != null) // filter by component
                {
                    var root = parent.GetComponentsInChildren(componentFilter);
                    foreach (var child in root)
                    {
                        child.gameObject.tag = tag.Value;
                    }
                }
            }

			Finish();
		}
		public bool GetActive(GameObject go){
			#if UNITY_3_0 || UNITY_3_0_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5	
			return go.active;
			#else
			return go.activeInHierarchy;
			#endif			
		}
Example #10
0
 void Awake()
 {
     player = GameObject.FindGameObjectWithTag ("Player");
     pHealth = player.GetComponent<PlayerHealth> ();
     eHealth = GetComponent<EnemyHealth> ();
     eMove = GetComponent<EnemyMovement> ();
 }
Example #11
0
 void SpawnCloud()
 {
     if (BoilerLid.lidIsOpen)
     {
         spawnedCloud = Instantiate(cloudToSpawn, new Vector3(-5.02f, 18.8f, 5.03f), transform.rotation) as GameObject;
     }
 }
Example #12
0
        void Start()
        {
            container = new GameObject("_ObjectPool");
            if (prefabsToPool == null) return;

            // AUTOPOOL: Find all Destructible objects with DestroyedPrefabs in the scene that have Auto-Pool set to TRUE.
            Destructible[] destructibleObjectsInScene = FindObjectsOfType<Destructible>();
            autoPooledObjects = new Dictionary<int, GameObject>();
            AddDestructibleObjectsToPool(destructibleObjectsInScene);

            // Instantiate game objects from the PrefabsToPool list and add them to the Pool.
            Pool = new GameObject[prefabsToPool.Count][];
            for (int i = 0; i < prefabsToPool.Count; i++)
            {
                PoolEntry poolEntry = prefabsToPool[i];
                Pool[i] = new GameObject[poolEntry.Count];
                for (int n=0; n<poolEntry.Count; n++)
                {
                    if (poolEntry.Prefab == null) continue;
                    var newObj = Instantiate(poolEntry.Prefab);
                    newObj.name = poolEntry.Prefab.name;
                    PoolObject(newObj);
                }
            }
        }
Example #13
0
        void DoSmoothLookAt()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);
            if (go == null)
            {
                return;
            }

            var goTarget = targetObject.Value;
            if (goTarget == null && targetPosition.IsNone)
            {
                return;
            }

            // re-initialize if game object has changed

            if (previousGo != go)
            {
                lastRotation = go.transform.rotation;
                desiredRotation = lastRotation;
                previousGo = go;
            }

            // desired look at position

            Vector3 lookAtPos;
            if (goTarget != null)
            {
                lookAtPos = !targetPosition.IsNone ?
                    goTarget.transform.TransformPoint(targetPosition.Value) :
                    goTarget.transform.position;
            }
            else
            {
                lookAtPos = targetPosition.Value;
            }

            if (keepVertical.Value)
            {
                lookAtPos.y = go.transform.position.y;
            }

            // smooth look at

            var diff = lookAtPos - go.transform.position;
            if (diff.sqrMagnitude > 0)
            {
                desiredRotation = Quaternion.LookRotation(diff, upVector.IsNone ? Vector3.up : upVector.Value);
            }

            lastRotation = Quaternion.Slerp(lastRotation, desiredRotation, speed.Value * Time.deltaTime);
            go.transform.rotation = lastRotation;

            // debug line to target

            if (debug.Value)
            {
                Debug.DrawLine(go.transform.position, lookAtPos, Color.grey);
            }
        }
        void DoSetFsmGameObject()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);
            if (go == null)
            {
                return;
            }

            if (go != goLastFrame)
            {
                goLastFrame = go;

                // only get the fsm component if go has changed

                fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value);
            }

            if (fsm == null)
            {
                return;
            }

            var fsmGameObject = fsm.FsmVariables.GetFsmGameObject(variableName.Value);

            if (fsmGameObject != null)

            {
                fsmGameObject.Value = setValue == null ? null : setValue.Value;
            }
        }
        public static int ComputeHull(GameObject gameObject, FracturedObject fracturedObject)
        {
            int nTotalTriangles = 0;

            if(ComputeHull(gameObject, fracturedObject.ConcaveColliderAlgorithm, fracturedObject.ConcaveColliderMaxHulls, fracturedObject.ConcaveColliderMaxHullVertices, fracturedObject.ConcaveColliderLegacySteps, fracturedObject.Verbose, out nTotalTriangles) == false)
            {
                if(fracturedObject.ConcaveColliderAlgorithm == FracturedObject.ECCAlgorithm.Fast)
                {
                    // Fast failed. Try with normal.
                    if(fracturedObject.Verbose)
                    {
                        Debug.Log(gameObject.name + ": Falling back to normal convex decomposition algorithm");
                    }

                    if(ComputeHull(gameObject, FracturedObject.ECCAlgorithm.Normal, fracturedObject.ConcaveColliderMaxHulls, fracturedObject.ConcaveColliderMaxHullVertices, fracturedObject.ConcaveColliderLegacySteps, fracturedObject.Verbose, out nTotalTriangles) == false)
                    {
                        if(fracturedObject.Verbose)
                        {
                            Debug.Log(gameObject.name + ": Falling back to box collider");
                        }
                    }
                }
            }

            return nTotalTriangles;
	    }
		public void SetActiveRecursively(GameObject go, bool isActive){
			#if UNITY_3_0 || UNITY_3_0_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5	
			go.SetActiveRecursively(isActive);
			#else
			go.SetActive(isActive);
			#endif
		}
 public static void CreatePattern(MenuCommand menuCommand)
 {
     var pattern = new GameObject("Pattern", typeof(Pattern));
     GameObjectUtility.SetParentAndAlign(pattern, menuCommand.context as GameObject);
     Undo.RegisterCreatedObjectUndo(pattern, "Create " + pattern.name);
     Selection.activeGameObject = pattern;
 }
Example #18
0
 public void PickupCoin(GameObject coin)
 {
     this._pickupSound.Play();
     Player.Instance.Points += 10;
     DestroyObject(coin);
     this.CreateNewCoin();
 }
		void Start(){
			if(cursorIndicatorMode!=_CursorIndicatorMode.None){
				if(indicatorBuildPoint!=null){
					indicatorBuildPoint=(GameObject)Instantiate(indicatorBuildPoint);
					indicatorBuildPoint.transform.localScale=new Vector3(gridSize, 1, gridSize);
					indicatorBuildPoint.transform.parent=transform;
					indicatorBuildPoint.SetActive(false);
					indicatorCursor.name="TileIndicator_BuildPoint";
					
					foreach(Transform child in indicatorBuildPoint.transform) 
						indicatorBuildPointRen=child.GetComponent<Renderer>();
				}
				
				if(indicatorCursor!=null){
					indicatorCursor=(GameObject)Instantiate(indicatorCursor);
					indicatorCursor.transform.localScale=new Vector3(gridSize, 1, gridSize);
					indicatorCursor.transform.parent=transform;
					indicatorCursor.SetActive(false);
					indicatorCursor.name="TileIndicator_Cursor";
					
					foreach(Transform child in indicatorCursor.transform) 
						indicatorCursorRen=child.GetComponent<Renderer>();
				}
			}
			
			InitiateSampleTowerList();
		}
        private void OnParticleCollision(GameObject other)
        {
            int safeLength = m_ParticleSystem.GetSafeCollisionEventSize();

            if (m_CollisionEvents.Length < safeLength)
            {
                m_CollisionEvents = new ParticleCollisionEvent[safeLength];
            }

            int numCollisionEvents = m_ParticleSystem.GetCollisionEvents(other, m_CollisionEvents);
            int i = 0;

            while (i < numCollisionEvents)
            {
                if (Time.time > lastSoundTime + 0.2f)
                {
                    lastSoundTime = Time.time;
                }

                var col = m_CollisionEvents[i].collider;
                var attachedRigidbody = col.GetComponent<Rigidbody>();
                if (attachedRigidbody != null)
                {
                    Vector3 vel = m_CollisionEvents[i].velocity;
                    attachedRigidbody.AddForce(vel*force, ForceMode.Impulse);
                }

                other.BroadcastMessage("Extinguish", SendMessageOptions.DontRequireReceiver);

                i++;
            }
        }
 //property nodes
 
 //method nodes
 #pragma warning restore 414
 
 //functions to refresh properties from entities
 
 void SyncUnityHooks( )
 {
    SyncEventListeners( );
    if ( null == local_3_UnityEngine_GameObject || false == m_RegisteredForEvents )
    {
       local_3_UnityEngine_GameObject = GameObject.Find( "LeftHandTouch" ) as UnityEngine.GameObject;
    }
    //if our game object reference was changed then we need to reset event listeners
    if ( local_3_UnityEngine_GameObject_previous != local_3_UnityEngine_GameObject || false == m_RegisteredForEvents )
    {
       //tear down old listeners
       
       local_3_UnityEngine_GameObject_previous = local_3_UnityEngine_GameObject;
       
       //setup new listeners
    }
    if ( null == local_4_UnityEngine_GameObject || false == m_RegisteredForEvents )
    {
       local_4_UnityEngine_GameObject = GameObject.Find( "RightHandTouch" ) as UnityEngine.GameObject;
    }
    //if our game object reference was changed then we need to reset event listeners
    if ( local_4_UnityEngine_GameObject_previous != local_4_UnityEngine_GameObject || false == m_RegisteredForEvents )
    {
       //tear down old listeners
       
       local_4_UnityEngine_GameObject_previous = local_4_UnityEngine_GameObject;
       
       //setup new listeners
    }
 }
 /// Create a new instance with a new timer component
 public AnimationHandler()
 {
   timerComponent = new GameObject();
   timerComponent.transform.name = "Animation Timer";
   var tc = timerComponent.AddComponent<AnimationTimerComponent>();
   tc.handler = this;
 }
        // We have many independent requests on the ImportBehaviour so we can't take for granted it has been created yet.
        // However, if it has been created then use it.
        public static ImportBehaviour FindOrCreateImportBehaviour(string xmlPath)
        {
            string importName = Path.GetFileNameWithoutExtension(xmlPath);

            // Try to find
            foreach (var status in UnityEngine.Object.FindObjectsOfType<ImportBehaviour>())
            {
                if (String.Compare(status.ImportName, importName, true) == 0)
                {
                    return status;
                }
            }

            // Couldn't find, so create.
            Debug.LogFormat("Tiled2Unity import status create for file {0}", xmlPath);
            GameObject gameObject = new GameObject("__temp_tiled2unity_import");
            gameObject.transform.SetAsFirstSibling();

            var importStatus = gameObject.AddComponent<ImportBehaviour>();
            importStatus.ImportName = Path.GetFileNameWithoutExtension(xmlPath);

            // Opening the XDocument itself can be expensive so start the progress bar just before we start
            importStatus.StartProgressBar(xmlPath);
            importStatus.XmlDocument = XDocument.Load(xmlPath);

            importStatus.numberOfElements = importStatus.XmlDocument.Element("Tiled2Unity").Elements().Count();
            importStatus.IncrementProgressBar(xmlPath);

            return importStatus;
        }
Example #24
0
        public static void Clear()
        {
            while ( spawnedObjects.Count > 0 )
            {
                if ( spawnedObjects.First.Value.IsInPool )
                    throw new Exception("Object was Despawned incorrectly");

                Despawn( spawnedObjects.First.Value );
            }

            foreach ( var pCollection in poolCollection )
                pCollection.Value.Clear();

            foreach ( var prefabPoolRecord in poolableDict )
                prefabPoolRecord.Value.CurrentAmount = 0;

            poolCollection.Clear();
            poolableDict.Clear();
            spawnedObjects.Clear();

            GameObject.Destroy( gameObject );

            gameObject = new GameObject();
            gameObject.name = "Prefab pool";
            GameObject.DontDestroyOnLoad(gameObject);
        }
Example #25
0
 private void DoGetFsmVector2()
 {
     if (this.storeValue == null)
     {
         return;
     }
     GameObject ownerDefaultTarget = base.Fsm.GetOwnerDefaultTarget(this.gameObject);
     if (ownerDefaultTarget == null)
     {
         return;
     }
     if (ownerDefaultTarget != this.goLastFrame)
     {
         this.goLastFrame = ownerDefaultTarget;
         this.fsm = ActionHelpers.GetGameObjectFsm(ownerDefaultTarget, this.fsmName.Value);
     }
     if (this.fsm == null)
     {
         return;
     }
     FsmVector2 fsmVector = this.fsm.FsmVariables.GetFsmVector2(this.variableName.Value);
     if (fsmVector == null)
     {
         return;
     }
     this.storeValue.Value = fsmVector.Value;
 }
Example #26
0
 private void Update()
 {
     if(_isGameStarted && mGameSessionGameObject == null)
         mGameSessionGameObject = GameObject.Find("GameSession");
     if(Math.Abs(Time.timeScale) < .25f)
         mMenuGameObject.SetActive(true);
 }
		//assign edilen objeler statik olmali
		public override void loadResources()
		{
			staticTowerObject = (GameObject)Resources.Load("3Ds/Towers/Physics/BallistaTower/TowerObject");            
			staticTowerIcon = (Texture2D)Resources.Load("3Ds/Towers/Physics/BallistaTower/GUI/towerIcon");
            staticCreateSound = (AudioClip)Resources.Load("Sound/tower_build");
			staticRangeProjector = ((GameObject)Resources.Load ("3Ds/Scenes/Game/RangeProjector")).GetComponent<Projector>();
		}
 public void Decorate(GameObject go, CustomSceneryV1 customScenery)
 {
     if (go.GetComponent<Deco>() != null)
     {
         go.GetComponent<Deco>().defaultGridSubdivision = customScenery.GridSubdivision;
     }
 }
Example #29
0
        public void Create(GameObject item, List<LoadItemInfo> list, float size)
        {
            foreach (var t in list)
            {
                var go = Instantiate(item);
                var rect = go.GetComponent<RectTransform>();
                rect.SetParent(gameObject.transform);
                rect.anchoredPosition3D = new Vector3(0, 0, 0);
                rect.localScale = new Vector3(1.0f, 1.0f, 1.0f);

                var scrollItem = go.GetComponent<ScrollItem>();

                scrollItem.Logo.sprite = t.Logo;
                scrollItem.Index.text = t.Index.ToString();
                scrollItem.Name.text = t.Type.ToString();
                scrollItem.Type = t.Type;

                Items.Add(scrollItem);
            }

            Size = 160;
            Shift = 0;

            var s = gameObject.GetComponent<RectTransform>().sizeDelta;
            s.y = size*list.Count;
            gameObject.GetComponent<RectTransform>().sizeDelta = s;
        }
Example #30
0
        // crea un chunk nella posizione indicata
        internal static Chunk CreateChunkAt(Vector3 posChunk, GameObject chunckContainer, int sizeChunk)
        {
            GameObject newChunk = new GameObject("chunck " + posChunk.x + " " + posChunk.y + " " + posChunk.z);
            newChunk.transform.parent = chunckContainer.transform;

            return Chunk.CreateComponent(newChunk, posChunk, sizeChunk);
        }