public override void Render(GameTime gameTime, SpriteBatch _spriteBatch) { foreach (Vector2 position in Game1.CalculateRenderPosition(Game1.getWithinField(Position))) { BehaviourUtil.RenderCircle(_spriteBatch, position, 5, Color.Black); } }
public void RenderFish(float gameTime, SpriteBatch _spriteBatch, Vector2 vector, Vector2 position, int texturenumber) { int currentsprite = (int)(gameTime * 2) % 4; Rectangle rectangle = new Rectangle((Fishx[currentsprite] + xStart[texturenumber]) * width, yStart[texturenumber] * height, width, height); _spriteBatch.Draw(Fishes, position, rectangle, Color.White, BehaviourUtil.GetRotation(vector) + (float)(Math.PI / 2), new Vector2(width / 2, height / 2), Vector2.One, SpriteEffects.None, 0); }
/// <summary> /// 播放一个特效 /// </summary> /// <param name="fxname"></param> /// <param name="loop"></param> /// <param name="fxtype"></param> /// <param name="parent"></param> /// <param name="trans"></param> /// <param name="lifetime"></param> /// <param name="alias"></param> /// <param name="limitry"></param> /// <returns></returns> public uint PlayFx(string fxname, bool loop, Transform parent = null, TransformData trans = null, float lifetime = -1, string alias = null, bool limitry = false) { ParticleData data = ParticleConfigManager.Instance.GetParticleData(fxname); if (data == null) { GameDebug.LogError("没有找到特效: " + fxname); return(uint.MaxValue); } uint instID = mLastEffectID++; ParticleItem item = new ParticleItem(); item.localTrans = trans; item.parent = parent; item.Alias = alias; item.LimitRy = limitry; item.Loop = loop; if (mEffects.ContainsKey(instID)) { mEffects.Remove(instID); } mEffects.Add(instID, item); BehaviourUtil.StartCoroutine(GenerateVisual(instID, fxname, item)); return(instID); }
//下载UI 会将引用的纹理集载入 public bool LoadUI(string _prefab, LoadUICallback callback) { string prefabName = _prefab + ".prefab"; if (!mConfig.WinDatas.ContainsKey(prefabName)) { //这里尝试使用 Resource.Load 来载入Resource下的预设 GameDebug.Log("包里没有找到UI " + prefabName); return(false); } //加入等待回调 if (!mLoadCallbacks.ContainsKey(prefabName)) { mLoadCallbacks.Add(prefabName, new ArrayList()); mLoadCallbacks[prefabName].Add(callback); WindowData data = mConfig.WinDatas[prefabName] as WindowData; BehaviourUtil.StartCoroutine(DownloadUI("Window/", prefabName, data.refAtlas)); } else { mLoadCallbacks[prefabName].Add(callback); } return(true); }
/// <summary> /// 安装数据 /// </summary> /// <param name="isInstall"></param> /// <param name="isCopyFile"></param> /// <returns></returns> protected IEnumerator InstallData(bool isInstall, bool isCopyFile) { yield return(BehaviourUtil.StartCoroutine(AndroidCopy(isCopyFile))); if (InstallDelegate != null) { InstallDelegate(); } }
public void Render(GameTime gameTime, SpriteBatch _spriteBatch) { if (Settings.RenderGrid && active) { foreach (Vector2 position in Game1.CalculateRenderPosition(Conections[0].Middle)) { BehaviourUtil.RenderVectorPrecise(_spriteBatch, drawvector, position, Length, color); } } }
public override void Render(GameTime gameTime, SpriteBatch _spriteBatch) { if (Settings.RenderObstacles) { Vector2 topleft = new Vector2(Position.X, Position.Y); foreach (Vector2 position in Game1.CalculateRenderPosition(topleft)) { BehaviourUtil.RenderCircle(_spriteBatch, position, Radius, Color.Green); } } }
private void onStartFlying() { BehaviourUtil.StartCoroutine(generateVisual((int)mBulletResource.bulletFigureID)); uint effectID = mBulletResource.effectOnTargetPosition; if (effectID != uint.MaxValue) { mAlertEffect = Scene.CreateEffect((int)effectID, Vector3.one, AlertEffectPosition, GetDirection()); } }
public bool SetupParticle(string effectName) { item = new ParticleItem(); item.localTrans = null; item.parent = null; item.Alias = null; item.LimitRy = false; item.Loop = false; BehaviourUtil.StartCoroutine(GenerateVisual(effectName, item)); return(true); }
/// <summary> /// 开始更新 /// </summary> public void StartUpdate() { //TODO:先检测主版本号,如果不匹配 if (true) { BehaviourUtil.StartCoroutine(LoadFileListFromServer()); } else { //TODO:Dosomething //CheckResource(); } }
/// <summary> /// 加载场景 /// </summary> /// <param name="name"></param> public void LoadScene(string name, SceneLoadComplete completedelegate, bool additive = false) { //Debug.Log("名字为" + name); SceneData data = SceneConfigManager.Instance.GetSceneData(name); if (data == null && completedelegate != null) { completedelegate(); return; } LoadComplete = completedelegate; BehaviourUtil.StartCoroutine(LoadScene_impl(data, additive)); }
public void DoUpdateSelf() { if (mDownLoadedIndex >= 10) { //没下载x个文件保存一下列表防止中途中断更新 mDownLoadedIndex = 0; SaveFileList(); } if ((mDownData.Count <= 0) && !isDownLoading) { SaveFileList(); if (OnUpdateComplete != null) { OnUpdateComplete(true); OnUpdateComplete = null; } } else { if (!Directory.Exists(mCachePath)) { Directory.CreateDirectory(mCachePath); } while ((mDownData.Count > 0) && !fullDownLoading) { ///如果列表里有需要下载的东西,并且非全速下载 ///执行一次下载 int index = downLoadIndex; if (index == -1) { Debug.LogError("DoUpdateSelf Error"); return; } ResData info = mDownData[0]; if (info == null) { Debug.LogError("DoUpdateSelf Error2"); return; } downLoadingDataInfoArray[index] = info; mDownData.RemoveAt(0); BehaviourUtil.StartCoroutine(WWWDownLoad(info.mDataPath, string.Format("{0}tmp{1}.ttdq", mCachePath, index), index)); } } }
void UpdateDay() { if (updateElapsed < updateGoal) { return; } updateElapsed -= UnityEngine.Random.Range(updateGoal * 0.5f, updateGoal * 2f); // Node-stuff and cult things // Have a chance of becoming breed ready again if (!canBreed && UnityEngine.Random.Range(0, 9) == 0) { canBreed = true; } // Checking to see if culty and near obelisks if (culty > 0) { GameObject obj = BehaviourUtil.NearestObjectByTag(this.gameObject, "Obelisk", 10); if (obj != null) { // Increment faith goes here ObeliskBehaviour ob = obj.transform.parent.GetComponent <ObeliskBehaviour>(); if (ob != null) { if (ob.isActive) { Faith.CurrentFaith += (Faith.obeliskGain / Faith.obeliskTimer) * Time.deltaTime; } } } } // Checking to see if faithy and near obelisks if (faithy > 0) { GameObject obelisk = BehaviourUtil.NearestObjectByTag(this.gameObject, "Obelisk", 10); if (obelisk != null) { // Disable the obelisk obelisk.BroadcastMessage("Disable"); } } }
public override void Destroy() { BehaviourUtil.StopCoroutine(generateVisual((int)mBulletResource.bulletFigureID)); if (mAlertEffect != uint.MaxValue) { Scene.RemoveEffect(mAlertEffect); } if (mVisual != null) { ParticleVisual.DestroyParticle(mVisual); mVisual = null; } mFlyController = null; mExplodeController = null; base.Destroy(); }
public void ChangeWeapon(int weaponid) { if (weaponid == mWeaponID) { return; } BehaviourUtil.StopCoroutine(ChangeWeapon_impl(mWeaponID)); if (!DataManager.WeaponTable.ContainsKey(weaponid)) { return; } if (mWeapon != null) { mWeapon.Destroy(); } foreach (uint effectid in mShowEffect) { SceneManager.Instance.GetCurScene().GetParticleManager().RemoveParticle(effectid); } mShowEffect.Clear(); mWeaponID = weaponid; //BehaviourUtil.StartCoroutine(ChangeWeapon_impl(weaponid)); WeaponTableItem mWeaopnRes = DataManager.WeaponTable[weaponid] as WeaponTableItem; mWeapon = new MeshVisual(); mWeapon.CreateWithConfig(AssetConfig.WeaponPath + mWeaopnRes.modelname, null, OnWeaponFailed, false); TransformData trans = new TransformData(); trans.Rot = new Vector3(90, 0, 0); trans.Scale = Vector3.one * mWeaopnRes.scale; ChangeAttach(AttachMountType.Weapon, mWeapon, mWeaopnRes.mountpoint, trans); }
public bool LoadAnimationRes(string aniName, LoadAnimationCallback callback) { string prefabName = aniName + ".prefab"; if (!mConfig.AniDatas.ContainsKey(prefabName)) { GameDebug.Log("包里没有找到Animation " + prefabName); return(false); } //加入等待回调 // if (!mAniLoadCallbacks.ContainsKey(prefabName)) // { // mAniLoadCallbacks.Add(prefabName, new ArrayList()); // } // mAniLoadCallbacks[prefabName].Add(callback); AnimationData data = mConfig.AniDatas[prefabName] as AnimationData; BehaviourUtil.StartCoroutine(DownloadAnimationRes(prefabName, data, callback, aniName)); return(true); }
public void CopyFileList() { BehaviourUtil.StartCoroutine(InstallData(true, true)); }
public void Init(FunctionCallback calback) { mInitCallback = calback; BehaviourUtil.StartCoroutine(InitConfigAndFonts()); }
public void LoadBytes(string path, ReadTextCallback callback) { BehaviourUtil.StartCoroutine(LoadBytes_impl(path, callback)); }
/// <summary> /// 下载程序文件 /// </summary> /// <param name="url"></param> public void UpdateClient(string url) { BehaviourUtil.StartCoroutine(HttpDownload(url)); }
// Update is called once per frame void Update() { updateElapsed += Time.deltaTime; if (DayNightCycle.Cycle.dayElapsed > DayNightCycle.Cycle.dayStart && DayNightCycle.Cycle.dayElapsed < DayNightCycle.Cycle.dayLength) { if (!isDay) { isDay = true; SetTarget(); if (isBaby) { ++daysAsChild; UpdateChild(); } } if (!isBaby) { UpdateDay(); } } else { if (isDay) { isDay = false; SetTarget(); } if (!isBaby) { UpdateNight(); } if (isSacrificable) { // If at sacrifice sacrific, and gain faiths! Vector3 delta = transform.position - altar.transform.position; Debug.Log(delta.magnitude); if (delta.magnitude <= 10) // Ideally 20, but 170 is the weirdness we are suffering through { Debug.Log("I want to sacrifice myself"); // Handle the sacrifice shit. ArrayList cultists = BehaviourUtil.SurroundingObjectsByTag(this.gameObject, "Entity", 20); // Reward faith based on number of cultists present if (cultists.Count > 0) { Faith.CurrentFaith += Faith.sacrificeGain * cultists.Count; AudioHandler.Instance.PlayVoiceOver(AudioHandler.VoiceOvers.WILHELMSCREAM); --Count; Destroy(this.gameObject); } } } } if (target == null) { UpdateNodes(); SetTarget(); } }
void UpdateNight() { if (updateElapsed < updateGoal) { return; } updateElapsed -= UnityEngine.Random.Range(updateGoal * 0.5f, updateGoal * 2f); // Breeding and sacrificing // Checking to see if you are flagged for sacrifice if (isSacrificable) { GameObject house = BehaviourUtil.NearestObjectByTag(this.gameObject, "House", 10); if (house != null) { role = "Virginy"; SetAppearance(); // Set Destination for sacrifice tablet altar = GameObject.Find("Altar"); navMe.SetDestination(altar.transform.position); } } else { // Checking to see if you are culty to go do culty stuffs if (culty > 0) { GameObject house = BehaviourUtil.NearestObjectByTag(this.gameObject, "House", 10); if (house != null) { GameObject altar = GameObject.Find("Altar"); navMe.SetDestination(altar.transform.position); } } else { if (Count < 100) { // Checking to see if opposite gender is close by (3-5) to breed GameObject house = BehaviourUtil.NearestObjectByTag(this.gameObject, "House", 10); if (house != null) { ArrayList entities = BehaviourUtil.SurroundingObjectsByTag(this.gameObject, "Entity", 5); if (entities != null) { foreach (GameObject obj in entities) { EntityBehaviour ent = obj.GetComponent <EntityBehaviour>(); if (ent != null) { if (ent.sex != sex) { if (!sex) { if (canBreed && Baby != null) { // Make baby canBreed = !canBreed; Instantiate(Baby, transform.position, new Quaternion()); } } } } } } } } } } }