string WhoFirst(ref Outman outman1, ref Outman outman2, float d1, float d2) { float t1 = d1 / outman1.Speed; float t2 = d2 / outman2.Speed; if (t1 < t2) { return(outman1.Name); } else if (t2 < t1) { return(outman2.Name); } else { return(outman1.Name + "和" + outman2.Name); } }
void RunQ4toQ6() { Outman Taro = new Outman(); Taro.Name = "泰罗"; Taro.Height = 53f; Taro.Weight = 55000f; Taro.Speed = 20f; // 马赫 Taro.Mother = "MotherofUltra"; Taro.BirthPlace = "M78"; Taro.CurrentLoc = "Andromeda"; Outman Seven21 = new Outman(); Seven21.Name = "赛文21"; Seven21.Height = 56f; Seven21.Weight = 57000f; Seven21.Speed = 26f; // 马赫 Seven21.Buddy = "Neos"; Seven21.BirthPlace = "M78"; Seven21.CurrentLoc = "M78"; float taroSpeed = CalculateSpeed(ref Taro); Debug.Log("泰罗奥特曼速度: " + taroSpeed + "米每秒"); float seven21Speed = CalculateSpeed(ref Seven21); Debug.Log("赛文21奥特曼速度: " + seven21Speed + "米每秒"); float distance_taro = 254f; // 光年 float distance_seven21 = 300f; // 光年 string firstCome = WhoFirst(ref Taro, ref Seven21, distance_taro, distance_seven21); Debug.Log(firstCome + "奥特曼会先到达地球。"); }
float CalculateSpeed(ref Outman outman) { return(outman.Speed * 340.3f); }