protected void GeneralStopImpact(ImpactLogicInfo logicInfo) { if (IsLogicDead(logicInfo.Target)) { SetGfxStateFlag(logicInfo.Target, Operate_Type.OT_RemoveBit, GfxCharacterState_Type.Stiffness); SetGfxStateFlag(logicInfo.Target, Operate_Type.OT_RemoveBit, GfxCharacterState_Type.HitFly); SetGfxStateFlag(logicInfo.Target, Operate_Type.OT_RemoveBit, GfxCharacterState_Type.GetUp); } else { ClearGfxStateFlag(logicInfo.Target); } logicInfo.CustomDatas.Clear(); //foreach=>for for (int i = 0; i < logicInfo.EffectsDelWithImpact.Count; ++i) { GameObject Obj = logicInfo.EffectsDelWithImpact[i]; ResourceSystem.RecycleObject(Obj); } //foreach(GameObject obj in logicInfo.EffectsDelWithImpact){ // ResourceSystem.RecycleObject(obj); //} ResetLayer(logicInfo.Target, logicInfo); LogicSystem.NotifyGfxAnimationFinish(logicInfo.Target, false); LogicSystem.NotifyGfxMoveControlFinish(logicInfo.Target, logicInfo.ImpactId, false); LogicSystem.NotifyGfxStopImpact(logicInfo.Sender, logicInfo.ImpactId, logicInfo.Target); }
async void RunTests() { await ResourceSystem.Init(); ResourceSystem.ResMode = ResourceSystem.Mode.AssetBundle; AssetSystem.Instance.disposeDelay = 2f; ResLog.Log("=== ResourceSystem Initialized ==="); foreach (Type type in testerTypes) { ResLog.LogFormat("=== Run {0} ===", type.Name); var go = new GameObject(); var tester = (Tester)go.AddComponent(type); try { await tester.Test(); } catch (Exception e) { ResLog.LogException(e); } Destroy(go); await Awaiters.NextFrame; ResLog.Log("=== Done ==="); } }
private void Update() { var resourceBankOfTeam = ResourceSystem.GetResourceBankOfTeam(team); if (resourceBankOfTeam == null) { return; } if (foodText != null) { foodText.text = resourceBankOfTeam.foodCount.ToString(); } if (woodText != null) { woodText.text = resourceBankOfTeam.woodCount.ToString(); } if (goldText != null) { goldText.text = resourceBankOfTeam.goldCount.ToString(); } if (stoneText != null) { stoneText.text = resourceBankOfTeam.stoneCount.ToString(); } }
void Start() { player = GameObject.FindGameObjectWithTag("Player"); resourceSystem = GetComponent <ResourceSystem>(); rigidBodyInf = player.GetComponent <RigidBodyInfo>(); moneyText2.text = resourceSystem.GetMoney().ToString() + "¥"; moneyText1.text = "+0¥"; audioManager = FindObjectOfType <AudioManager>(); if (inGameHub) { // Set up for when in the game hub overlay.sprite = spriteOverlay[0]; boostText.gameObject.SetActive(false); fishText.gameObject.SetActive(false); timeText.gameObject.SetActive(false); moneyText1.gameObject.SetActive(false); moneyText2.gameObject.SetActive(true); } else if (!inGameHub) { currentFishAmount = missionManager.fishLeft; fishText.text = currentFishAmount + "/" + missionManager.fishMax; } }
// Update is called once per frame void Update() { if (IsActive) { if (Time.time < m_LastTriggerTime + m_AnimationPlayer.AnimationLenth(m_StartAnim)) { } else if (Time.time < m_LastTriggerTime + m_AnimationPlayer.AnimationLenth(m_StartAnim) + m_MovingTime) { if (!m_AnimationPlayer.IsPlaying(m_RotateAnim)) { m_AnimationPlayer.Play(m_RotateAnim); } if (!m_HasRotateEffect) { m_HasRotateEffect = true; if (null != m_RotateEffect) { GameObject rotateEffect = ResourceSystem.NewObject(m_RotateEffect, m_MovingTime) as GameObject; if (null != rotateEffect) { Transform parent = LogicSystem.FindChildRecursive(this.transform, m_RotateEffectBone); if (null != parent) { rotateEffect.transform.parent = parent; rotateEffect.transform.localPosition = Vector3.zero; rotateEffect.transform.localRotation = Quaternion.identity; m_EffectList.Add(rotateEffect); } } } } Vector3 motion = m_Direction * Time.deltaTime * m_Speed; if (!m_MoveController.isGrounded) { motion.y += -9.8f * Time.deltaTime; } m_MoveController.Move(m_Direction * Time.deltaTime * m_Speed); LogicSystem.NotifyGfxUpdatePosition(gameObject, this.transform.position.x, this.transform.position.y, this.transform.position.z, 0, this.transform.rotation.eulerAngles.y * Mathf.PI / 180f, 0); HandleDamage(); } else if (Time.time < m_LastTriggerTime + m_AnimationPlayer.AnimationLenth(m_StartAnim) + m_MovingTime + m_AnimationPlayer.AnimationLenth(m_EndAnim)) { if (!m_AnimationPlayer.IsPlaying(m_EndAnim)) { SetEndure(gameObject, false); m_AnimationPlayer.Play(m_EndAnim); } } else { StopSkill(); } if (IsLogicDead()) { NotifyNpcDead(gameObject); StopSkill(); } } }
public void LoadAsset(GameEntity entity, uint resId, string asset, float scale, Vector3 position) { var viewObject = ResourceSystem.NewObject(asset) as GameObject; if (null != viewObject) { viewObject.transform.localScale = Vector3.one * scale; viewObject.transform.localPosition = position; var view = viewObject.GetComponent <IView>(); if (null != view) { // add view; view.Init(entity); entity.AddView(view); } var rigidbody = viewObject.GetComponent <IRigidbody>(); if (null != rigidbody) { entity.AddPhysics(rigidbody, Vector3.zero); } viewObject.Link(entity, Contexts.sharedInstance.game); } else { LogUtil.Error("GfxMoudle.Instantiate new object failed. Resource path is {0}.", asset); } }
public bool PlayAnimation(string path, AnimPlayType type, float speed = 1.0f, bool loop = false, bool reverse = false, float fadeLength = 0.15f, float time = 0.0f, bool async = true) { if (type == AnimPlayType.Priority) { Debug.LogError("高优先级动画请用PlayPriorityAnimation播放!"); return(false); } if (string.IsNullOrEmpty(path)) { return(false); } if (async) { // 未来Lambda改成Request ResourceSystem.LoadAsync <AnimationClip>(path, (o) => { AnimationClip c = o as AnimationClip; if (c == null) { return; } PlayClipAnimation(c, c.name, type, speed * mAnimSpeed, loop, reverse, fadeLength, time); }); } else { AnimationClip c = ResourceSystem.Load <AnimationClip>(path); if (c == null) { return(false); } PlayClipAnimation(c, c.name, type, speed * mAnimSpeed, loop, reverse, fadeLength, time); } return(true); }
// Update is called once per frame void Update() { if (Time.time > m_LastBornTime + m_BornInterval) { m_LastBornTime = Time.time; if (null != m_MonsterPrefab) { GameObject monster = ResourceSystem.NewObject(m_MonsterPrefab) as GameObject; if (null != monster) { monster.transform.position = this.transform.position; monster.transform.rotation = m_MatchTransform.rotation; m_Monsters.Add(monster); monster.SendMessage("SetMatchTransform", m_MatchTransform); } } } /* * foreach (GameObject monster in m_Monsters) { * Animator animator = monster.GetComponent<Animator>(); * if (null != animator) { * if (Vector3.Distance(this.transform.position, monster.transform.position) > m_ClimbStopDistance) { * animator.SetBool("StartClimp", true); * monster.transform.position += m_ClimbSpeed * this.transform.up * Time.deltaTime; * } else { * animator.SetBool("StartClimp", false); * animator.SetBool("ClimpEnd", true); * } * } * } */ }
protected override void OnEvent(bool paramBool) { if (paramBool) { if (spawnTemplate != null) { return; } if (m_spawnRef != null) { ResourceSystem.Load <GameObject>(m_spawnRef, OnLoadComplete); } else if (string.IsNullOrEmpty(m_spawnResource)) { ResourceSystem.Load <GameObject>(m_spawnResource, OnLoadComplete); } else if (m_spawnObj != null) { OnLoadComplete(m_spawnObj); } } else { if (spawnedObj) { Destroy(spawnedObj); } } }
public void InstallInputProvider(InputProvider inputPrefab) { if (!inputPrefab) { //Debug.LogError("Invalid InputProvider (null)"); return; } //Debug.Log("TouchManager: using " + inputPrefab.name); if (inputProvider) { Destroy(inputProvider.gameObject); } inputProvider = ResourceSystem.NewObject(inputPrefab) as InputProvider; inputProvider.name = inputPrefab.name; inputProvider.transform.parent = this.transform; InitFingers(MaxFingers); if (OnInputProviderChanged != null) { OnInputProviderChanged(); } }
public void LoadingSimple() { ResourceSystem.Create(Config, new List <Resource> { Dummy(), Silly() }); }
public void AddDamageText(GameEntity entity, string text, long remainTime) { UnityView view = entity.view.Value as UnityView; if (null != view) { var hudObject = ResourceSystem.NewObject("HudText") as GameObject; hudObject.transform.SetParent(UIRoot, false); hudObject.transform.localPosition = Vector3.zero; DamageInfo hudInfo = new DamageInfo(); hudInfo.Obj = hudObject; UnityEngine.UI.Text uiText = hudObject.GetComponentInChildren <UnityEngine.UI.Text>(); if (null != uiText) { uiText.text = text; } hudInfo.SelfTransform = hudObject.GetComponentInChildren <RectTransform>(); hudInfo.Position = view.gameObject.transform.position + Vector3.up * 2; hudInfo.DeleteTime = Time.time + remainTime / 1000.0f; hudInfo.FloatSpeed = m_FloatSpeed; hudInfo.Delay = m_DelayStay + Time.time; hudInfo.Movement = Guidance.LeftUp; m_Damages.Add(hudInfo); } }
// Public: public GameMapBatchLoader(ResourceSystem resourceSystem, MapChunk mapChunk, GameModeChunk gameModeChunk) : base(resourceSystem, true, GetEntriesToLoad(resourceSystem, mapChunk, gameModeChunk)) { this.mapChunk = mapChunk; this.gameModeChunk = gameModeChunk; this.sceneAssetBundle = resourceSystem.GetSceneAssetBundle(mapChunk.SceneBundleName.Name); }
async void Init() { await ResourceSystem.Init(); modeSelector.Init(); AddOptions(); initialized = true; }
static bool Prefix(ResourceSystem __instance, byte faction, ref ResourceCost buildCost) { if (faction == __instance.Battle.LocalPlayerFactionId) { Traverse.Create(buildCost).Property("PopulationCost").SetValue(0); } return(true); }
public virtual void UpdateEffect(ImpactLogicInfo logicInfo) { if (null == logicInfo.Target) { return; } SharedGameObjectInfo shareInfo = LogicSystem.GetSharedGameObjectInfo(logicInfo.Target); if (null != shareInfo && !shareInfo.AcceptStiffEffect) { return; } for (int i = 0; i < logicInfo.EffectList.Count; ++i) { EffectInfo effectInfo = logicInfo.EffectList[i]; if (null != effectInfo) { if (effectInfo.StartTime < 0 && Time.time > logicInfo.StartTime + effectInfo.DelayTime / 1000) { effectInfo.IsActive = true; effectInfo.StartTime = Time.time; GameObject obj = ResourceSystem.NewObject(effectInfo.Path, effectInfo.PlayTime / 1000) as GameObject; if (null != obj) { if (effectInfo.DelWithImpact) { logicInfo.EffectsDelWithImpact.Add(obj); } if (String.IsNullOrEmpty(effectInfo.MountPoint)) { obj.transform.position = logicInfo.Target.transform.position + effectInfo.RelativePoint; UnityEngine.Quaternion q = UnityEngine.Quaternion.Euler(effectInfo.RelativeRotation.x, effectInfo.RelativeRotation.y, effectInfo.RelativeRotation.z); if (effectInfo.RotateWithTarget && null != logicInfo.Sender) { obj.transform.rotation = UnityEngine.Quaternion.LookRotation(logicInfo.Target.transform.position - logicInfo.Sender.transform.position, UnityEngine.Vector3.up); obj.transform.rotation = UnityEngine.Quaternion.Euler(obj.transform.rotation.eulerAngles + effectInfo.RelativeRotation); } else { obj.transform.rotation = q; } } else { Transform parent = LogicSystem.FindChildRecursive(logicInfo.Target.transform, effectInfo.MountPoint); if (null != parent) { obj.transform.parent = parent; obj.transform.localPosition = UnityEngine.Vector3.zero; UnityEngine.Quaternion q = UnityEngine.Quaternion.Euler(ImpactUtility.RadianToDegree(effectInfo.RelativeRotation.x), ImpactUtility.RadianToDegree(effectInfo.RelativeRotation.y), ImpactUtility.RadianToDegree(effectInfo.RelativeRotation.z)); obj.transform.localRotation = q; } } } } } } }
public override void StartSkill() { GeneralStartSkill(); m_HasRotateEffect = false; GameObject player = LogicSystem.PlayerSelf; if (null != player) { m_Direction = player.transform.position - this.transform.position; m_Direction.y = 0; m_Direction.Normalize(); RaycastHit hit; Vector3 pos = this.transform.position; pos.y += 0.5f; if (Physics.Raycast(pos, m_Direction, out hit, m_MaxDis, m_LayerMask)) { m_TargetPos = hit.point; } else { m_TargetPos = this.transform.position + m_Direction * m_MaxDis; } m_MovingTime = Vector3.Distance(this.transform.position, m_TargetPos) / m_Speed; m_LastImpactTime = 0.0f; m_AnimationPlayer.Play(m_StartAnim); SetEndure(gameObject, true); if (null != m_WarningEffect) { GameObject warnEffect = ResourceSystem.NewObject(m_WarningEffect, m_AnimationPlayer.AnimationLenth(m_StartAnim)) as GameObject; if (null != warnEffect) { warnEffect.transform.position = this.transform.position + new Vector3(0.0f, 0.1f, 0.0f); warnEffect.transform.rotation = Quaternion.LookRotation(m_Direction); m_EffectList.Add(warnEffect); } } if (null != m_BurnEffect) { float duration = m_AnimationPlayer.AnimationLenth(m_StartAnim) + m_AnimationPlayer.AnimationLenth(m_EndAnim) + m_MovingTime; GameObject burnEffect = ResourceSystem.NewObject(m_BurnEffect, duration) as GameObject; if (null != burnEffect) { Transform parent = LogicSystem.FindChildRecursive(this.transform, "Bip001 Spine1"); if (null != parent) { burnEffect.transform.parent = parent; burnEffect.transform.localPosition = Vector3.zero; burnEffect.transform.localRotation = Quaternion.identity; m_EffectList.Add(burnEffect); } } } } else { StopSkill(); } }
// Methods private void CreateFileLogger() { if (_filename.Contains("/") || _filename.Contains("\\")) { ResourceSystem.CreateDirectory(_filename); } _stream = new StreamWriter(_filename); }
public void RecylceAsset(GameEntity entity) { if (entity.hasView) { UnityView view = entity.view.Value as UnityView; view.gameObject.Unlink(); ResourceSystem.RecycleObject(view.gameObject); } }
private void OnHitTarget(GameObject obj) { ImpactInfo impact = m_ImpactInfo.Clone() as ImpactInfo; impact.Attacker = m_Sender; impact.m_Velocity = this.transform.forward * impact.m_Velocity.z; ImpactSystem.Instance.SendImpact(m_Sender, obj, impact.Clone() as ImpactInfo); ResourceSystem.RecycleObject(gameObject); }
static void Prefix(ResourceSystem __instance, byte faction, ResourceType type, ResourceChangeReason changeReason, ref int amount) { if (faction == __instance.Battle.LocalPlayerFactionId && (type == ResourceType.Iron || type == ResourceType.Oil) && changeReason == ResourceChangeReason.Production) { //logger.LogDebug($"Patch_GrantResource for faction {faction} for resource {type}: {amount}"); amount *= 2; } }
public override void Reset() { m_IsInited = false; SetBlackPercent(0); Camera.main.cullingMask = m_OldMask; Camera.main.clearFlags = UnityEngine.CameraClearFlags.Skybox; ResourceSystem.RecycleObject(m_BlackCameraObj); m_BlackCameraObj = null; m_BlackCamera = null; }
protected void PlayImpactEffect(GameObject effectPrefab, Vector3 position, float playTime) { GameObject obj = ResourceSystem.NewObject(effectPrefab, playTime) as GameObject; if (null != obj) { obj.transform.position = this.transform.TransformPoint(position); obj.transform.rotation = Quaternion.identity; } }
public void UnknownType_ReturnsEmpty() { var system = ResourceSystem.Create(Config, new List <Resource> { Dummy(), Silly(), Silly() }); var grumpyResources = system.GetAll <GrumpyResource>(); IsNotNull(grumpyResources); IsEmpty(grumpyResources); }
public void CanResolveRef() { var resource = Dummy(); var system = ResourceSystem.Create(Config, new List <Resource> { Dummy(), Silly(), resource }); var resolved = resource.ToRef().Resolve(system); AreEqual(resource, resolved); }
public void DuplicateId_IgnoresDuplicates() { var resource = Dummy(); var resourceDuplicate = Dummy(resource.ResourceId); var system = ResourceSystem.Create(Config, new List <Resource> { resource, Silly(), resourceDuplicate, Dummy() }); AreEqual(resource, system.Resolve(resource.ToRef())); IsTrue(system.GetAll <DummyResource>().Contains(resource)); }
public override void StopImpact(ImpactLogicInfo logicInfo) { for (int i = 0; i < logicInfo.EffectsDelWithImpact.Count; i++) { ResourceSystem.RecycleObject(logicInfo.EffectsDelWithImpact[i]); } /* * foreach(GameObject obj in logicInfo.EffectsDelWithImpact){ * ResourceSystem.RecycleObject(obj); * }*/ logicInfo.IsActive = false; }
private void PlayParticle(UnityEngine.Vector3 nguiPos) { if (effect != null) { UnityEngine.GameObject ef = ResourceSystem.NewObject(effect) as GameObject; if (ef != null) { nguiPos.Set(-0.17f, nguiPos.y, nguiPos.z); ef.transform.position = nguiPos; Destroy(ef, duration); } } }
public void StopEffects() { for (int i = 0; i < m_EffectObject.Count; i++) { ResourceSystem.RecycleObject(m_EffectObject[i]); } /* * foreach (GameObject effect in m_EffectObject) { * ResourceSystem.RecycleObject(effect); * }*/ m_EffectObject.Clear(); }
protected override void Load(ScriptableData.CallData callData) { if (callData.GetParamNum() >= 3) { m_StartTime = long.Parse(callData.GetParamId(0)); m_RemainTime = long.Parse(callData.GetParamId(1)); string materialname = callData.GetParamId(2); Material material = ResourceSystem.GetSharedResource(materialname) as Material; if (material != null) { m_SBMRemain = material; } } }