/********************************* Biu Biu Biu ***********************************/ #endregion #region Methods /// <summary> /// 播放指示条动画 /// </summary> /// <param name="Angle"></param> void BeginIndicatorValueChangedAnimation(double Angle) { if (Angle < 5) // 如果EndAngle小于5度,则直接显示角度值,QuinticEase会造成过冲,EndAngle会变成负值,造成闪动 { /* 如果上一个动画还在执行中,则先停止动画 * 否则执行中的动画可能再次更改EndAngle */ if (animationclock != null && animationclock.CurrentState != ClockState.Stopped) { animationclock.Controller.Stop(); } IndicatorBar.EndAngle = Angle; } else { animation = new DoubleAnimation(); animation.Duration = new Duration(TimeSpan.FromMilliseconds(500)); animation.To = Angle; // QuinticEase ease = new QuinticEase(); ElasticEase ease = new ElasticEase() { Oscillations = 2, Springiness = 5 }; ease.EasingMode = EasingMode.EaseOut; animation.EasingFunction = ease; animationclock = animation.CreateClock(); animationclock.Completed += animationclock_Completed; IndicatorBar.ApplyAnimationClock(Arc.EndAngleProperty, animationclock, HandoffBehavior.SnapshotAndReplace); animationclock.Controller.Begin(); } }
public CombatController SpawnCombatAvatar(Vector3 location, Quaternion rotation, bool asPC) { dead = false; if (currentHealth <= 0) { currentHealth = 1; } GameObject combatPrefab = (GameObject)Resources.Load("Prefabs/Combat/" + avatarFileName, typeof(GameObject)); avatar = GameObject.Instantiate(combatPrefab, location, rotation) as GameObject; healthBar = avatar.transform.Find("Canvas").transform.Find("HealthBar").GetComponent <IndicatorBar>(); healthBar.SetSliderMax(MaxHealth()); healthBar.SetSlider(currentHealth); manaBar = avatar.transform.Find("Canvas").transform.Find("ManaBar").GetComponent <IndicatorBar>(); manaBar.SetSliderMax(MaxMana()); manaBar.SetSlider(currentMana); avatar.AddComponent <ActionMove>(); avatar.AddComponent <ActionBasicAttack>(); if (asPC) { combatController = avatar.AddComponent <PlayerController>(); } else { combatController = avatar.AddComponent <EnemyController>(); } combatController.SetCharacterSheet(this); GameObject.FindObjectOfType <TurnManager>().combatants.Add(combatController); // List<Action> specialMoves = new List<Action> { }; return(combatController); }
public static JobComponent ScheduleJobControllerInWorld( WorldComponent worldComponent, Job job) { GameObject entityObject = new GameObject(); JobComponent entityComponent = entityObject.AddComponent <JobComponent>(); entityObject.transform.SetParent(worldComponent.transform); IndicatorBar bar = IndicatorBar.Instantiate(entityObject); bar.GetSizeCallback = new IndicatorBar.GetSize( () => { return(job.CurrentStage().CurrentProgress()); } ); entityObject.name = job.id + "_indicator"; entityComponent.job = job; PolygonCollider2D collider = entityObject.AddComponent <PolygonCollider2D>(); collider.points = new Vector2[] { new Vector2(-0.5f, -0.5f), new Vector2(-0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, -0.5f) }; entityComponent.spriteRenderer = entityObject.AddComponent <SpriteRenderer>(); entityComponent.spriteRenderer.sprite = SpriteLoader.GetSprite("test"); return(entityComponent); }
static public IndicatorBar Instantiate(GameObject parent) { GameObject go = new GameObject(); go.transform.SetParent(parent.transform); go.name = "indicator_bar"; IndicatorBar jobComponent = go.AddComponent <IndicatorBar>(); return(jobComponent); }
public void Init(int inputMaxHealth, int inputCurrentHealth, int spe, int end, int str, int agi, int intel, string name) { displayName = name; speed = spe; endurance = end; strength = str; agility = agi; intelligence = intel; rng = new System.Random(); healthBarScript = transform.Find("HealthBar").GetComponent <IndicatorBar>(); staminaBarScript = transform.Find("StaminaBar").GetComponent <IndicatorBar>(); maxHealth = inputMaxHealth; maxStamina = endurance * 15 + 10; currentStamina = maxStamina; currentHealth = inputCurrentHealth; maxConcentration = 20 + GetEffectiveIntelligence() * 3; healthBarScript.SetPercent(PercentHealth()); }