void CreateTexture() { tex = new Texture2D((int)monster[0].sprite.rect.width, (int)monster[0].sprite.rect.height); Color[] currPixels = null; int[] order = { 3, 4, 2, 1, 0 }; foreach (int i in order) { Color[] pixels = monster[i].sprite.texture.GetPixels(); if (currPixels == null) { currPixels = pixels; } else { for (int j = 0; j < currPixels.Length; j++) { if (pixels[j].a != 0.0f) { currPixels[j] = pixels[j]; } } } } tex.SetPixels(currPixels); tex.Apply(); TextureCharacter.getInstance().tex = tex; }
// Use this for initialization void Start() { explo = GameObject.Find("Explosions").GetComponent <ParticleSystem>(); //server = GameObject.Find("Server").GetComponent<Server>(); scoreText = GameObject.Find("ScoreText").GetComponent <Text> (); timerText = GameObject.Find("TimerText").GetComponent <Text> (); calibrateScreen = GameObject.Find("CalibrateScreen").GetComponent <CanvasGroup> (); canvas = GameObject.Find("Canvas"); canvasTransform = canvas.GetComponent <RectTransform>().position; score = 0; timer = 10; timerText.text = timer.ToString(); positions = new Dictionary <string, Vector3>(); targets = new Dictionary <string, GameObject>(); firing = new Dictionary <string, bool>(); mouseTesting = GameObject.Find("MouseTesting").GetComponent <MouseTesting>(); if (TextureCharacter.getInstance().tex != null) { enemyMat.mainTexture = TextureCharacter.getInstance().tex; } else { enemyMat.mainTexture = defaultEnemyTex; } //server.SetupServer(); //server.RegisterHandler(ActionMessage.id, OnReceivedActionMessage); //server.RegisterHandler(CalibrationMessage.id, calibration.OnCalibrationMessageReceived); socketClient = SocketClient.GetInstance(); socketClient.ChangeMode(1); socketClient.updateEventCallbacks += OnReceivedUpdateMessage; socketClient.fireEventCallbacks += OnReceivedFireMessage; myEnemiesComp = GameObject.Find("EnemiesManager").GetComponent <Enemies> (); StartCoroutine(GameCoroutine()); }