// Update is called once per frame void Update() { if (decalManager == null) { if (GameObject.Find("DecalManager") != null) { decalManager = GameObject.Find("DecalManager").GetComponent <DecalManager> (); } } if (isLocalPlayer) { //INPUTS MUST GO HERE if (hasGun) { if (isAutomatic) { //Automatic Guns if (Input.GetMouseButton(0) && Time.time - lastFireTime > fireDelay) { Fire(); } } else { //Automatic Guns if (Input.GetMouseButtonDown(0) && Time.time - lastFireTime > fireDelay) { Fire(); } } } } }
void Start() { if (instance == null) { instance = this; } }
public void GenerateDecal(Texture2D hitTexture, GameObject affectedObj) { transform.Rotate(new Vector3(0, 0, Random.Range(-180.0f, 180.0f))); //<<91-04-14>> transform.localScale *= Random.Range(0.7f, 1.5f); //<<\91-04-14>> Decal.dCount++; Decal decal = gameObject.GetComponent <Decal>(); decal.affectedObjects = new GameObject[1]; decal.affectedObjects[0] = affectedObj; decal.decalMode = DecalMode.MESH_COLLIDER; decal.pushDistance = 0.08f + DecalManager.Add(gameObject); //decal.pushDistance = 0.019f; Material mat = new Material(decal.decalMaterial); mat.mainTexture = hitTexture; decal.decalMaterial = mat; decal.CalculateDecal(); decal.transform.parent = affectedObj.transform; }
public void Add_Decal(ParticleSystem.Particle new_decal, DecalManager dm) { if (m_DecalManager == null) { m_DecalManager = dm; } m_Decals.Add(new_decal); }
public void GenerateMark(Texture2D hitTexture, RaycastHit hitInfo) { transform.Rotate(new Vector3(0, Random.Range(-180.0f, 180.0f), 0)); transform.localScale *= Random.Range(0.6f, 0.8f); transform.position += hitInfo.normal * DecalManager.Add(gameObject); transform.parent = hitInfo.collider.transform; renderer.material.mainTexture = hitTexture; }
//Singleton private void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Debug.Log("Instance already exists, destroying object."); Destroy(this); } }
// Use this for initialization public void Start() { try { m_decalManager = this.transform.Find("Decal").GetComponent <DecalManager>(); } catch { m_decalManager = null; Debug.Log("No Decal found on " + this.name); } particleTransformName = GLOBAL_VALUES.PARTICLE_TRANSFORM_NAME; saleMultiplier = GLOBAL_VALUES.SALE_SCORE_MULTIPLIER; for (int i = 1; i <= 4; i++) { m_Outlines.Add(transform.Find("Outline" + i).gameObject); } foreach (GameObject go in m_Outlines) { go.SetActive(false); } for (int i = 0; i < previous_movements.Length; i++) { previous_movements[i] = Vector3.zero; } //Sound source = GetComponent <AudioSource>(); land = Resources.Load <AudioClip>(GLOBAL_VALUES.SOUND_ITEM_LAND); impact = Resources.Load <AudioClip>(GLOBAL_VALUES.SOUND_ITEM_IMPACT); //Particle Effects motionEffects = gameObject.transform.Find("Item_Trail").gameObject; motionEffects.SetActive(false); // Initialize base value (static throughout round) baseValue = value; if (OnSale) { StartSale(); } else { EndSale(); } SetState(ItemState.idle); }
public static float Add(GameObject go) { if (instance == null) { GameObject aux = new GameObject("DecalManager"); instance = aux.AddComponent <DecalManager>(); instance.Marks = new ArrayList(); instance.PushDistances = new ArrayList(); instance.MaxMarks = 50; } GameObject auxGo; Transform auxT; Transform currentT = go.transform; Vector3 currentPos = currentT.position; float radius = (currentT.localScale.x * currentT.localScale.x * 0.25f) + (currentT.localScale.y * currentT.localScale.y * 0.25f) + (currentT.localScale.z * currentT.localScale.z * 0.25f); //I change The Radius Here is first numbers: //radius = Mathf.Sqrt(radius); //float realRadius = radius * 2; //radius *= 0.2f; radius = Mathf.Sqrt(radius); float realRadius = radius * 8f; radius *= 3f; float distance; if (instance.Marks.Count == instance.MaxMarks) { auxGo = instance.Marks[0] as GameObject; Destroy(auxGo); instance.Marks.RemoveAt(0); instance.PushDistances.RemoveAt(0); } float pushdistance = 0.0001f; int lenght = instance.Marks.Count; //int sideMarks = 0; //GameObject sphereTest = GameObject.CreatePrimitive(PrimitiveType.Sphere); //sphereTest.transform.position = currentPos; //sphereTest.transform.localScale = new Vector3(radius * 4f, radius * 8f, radius * 8f); for (int i = 0; i < lenght; i++) { auxGo = instance.Marks[i] as GameObject; if (auxGo != null) { auxT = auxGo.transform; distance = (auxT.position - currentPos).magnitude; if (distance < radius) { Destroy(auxGo); instance.Marks.RemoveAt(i); instance.PushDistances.RemoveAt(i); i--; lenght--; } else if (distance < realRadius) { float cDist = (float)instance.PushDistances[i]; //if (cDist >= pushdistance) // pushdistance = cDist * 1.3f; pushdistance = Mathf.Max(pushdistance, cDist); } } else { instance.Marks.RemoveAt(i); instance.PushDistances.RemoveAt(i); i--; lenght--; } } pushdistance += 0.0035f; instance.Marks.Add(go); instance.PushDistances.Add(pushdistance); //DebugTest.Instance.testString = pushdistance.ToString(); return(pushdistance); }
protected override void Awake() { base.Awake(); decalManager = Dependency.Get<DecalManager>(); }