public void Initialize(Balloon parent)
    {
        balloon = parent;

        meshRenderer = balloon.GetComponent <MeshRenderer> ();
        meshFilter   = balloon.GetComponent <MeshFilter> ();

        mesh = meshFilter.mesh;
    }
Esempio n. 2
0
    private void CreateNewBalloon(float rotationDegrees)
    {
        Balloon newBalloon = (Balloon)Instantiate(balloonPrefab, transform.position, Quaternion.identity);

        newBalloon.name = "BalloonPrefab";
        newBalloon.transform.localScale *= sizeDecrement;
        newBalloon.balloonsInCluster     = this.balloonsInCluster / 2;
        LinearFlight flight = newBalloon.GetComponent <LinearFlight>();

        flight.IncrementSpeed();
        flight.RotateFlightDirection(rotationDegrees);
    }
Esempio n. 3
0
    // 静态方法,通过引用prefab将他实例化创建GameObject,便于在点击打气筒时创建实例
    public static Balloon Create(Vector3 pos, Vector3 scale, Color color, float degree)
    {
        GameObject prefab        = Resources.Load <GameObject>("Prefabs/balloon");
        GameObject balloonSprite = (GameObject)Instantiate(prefab, pos, Quaternion.identity); // 创建实例
        Balloon    balloon       = balloonSprite.AddComponent <Balloon>();

        balloon.transform.localScale = scale;
        balloon.m_degree             = degree;
        balloon.GetComponent <SpriteRenderer>().color = color;
        balloon.isBlowing = true;
        return(balloon);
    }
Esempio n. 4
0
    void CreateBalloonClusters()
    {
        for (int i = 0; i < numBalloonClusters; i++)
        {
            Vector3 randomPosition = new Vector3(UnityEngine.Random.Range(0.2f, 0.8f), UnityEngine.Random.Range(0.2f, 0.8f), 10.0f);
            Vector3 worldPos       = Camera.main.ViewportToWorldPoint(randomPosition);
            Balloon balloonCluster = (Balloon)Instantiate(balloonPrefab, worldPos, Quaternion.identity);
            balloonCluster.name = "BalloonCluster";
            LinearFlight flight = balloonCluster.GetComponent <LinearFlight>();
            flight.RotateFlightDirection(UnityEngine.Random.Range(0f, 360f));

            balloonClusters.Add(balloonCluster);
        }
    }
Esempio n. 5
0
 // Update is called once per frame
 void Update()
 {
     if ((Balloon.GetComponent <TalkBalloon> ().NumberOfTalk() >= NeedTalkCount) && !DialogPanel.activeSelf)
     {
         ShopItem1.GetComponent <Button> ().enabled  = true;
         ShopItem2.GetComponent <Button> ().enabled  = true;
         buyButton1.GetComponent <Button> ().enabled = true;
         buyButton2.GetComponent <Button> ().enabled = true;
         QuestionBox1.SetActive(false);
         QuestionBox2.SetActive(false);
         if (!IsAlreadyOpen)
         {
             PopUpText.text = "이제 상점에서 <" + ItemName1 + ">와 <" + ItemName2 + ">을 구입할 수 있습니다!";
             PopUpClose.SetActive(true);
             PopUp.SetActive(true);
             IsAlreadyOpen = true;
         }
     }
     save();
 }
Esempio n. 6
0
    // Update is called once per frame
    void Update()
    {
        if ((Balloon.GetComponent <TalkBalloon> ().NumberOfTalk() >= NeedTalkCount) && !DialogPanel.activeSelf)
        {
            ShopItem1.GetComponent <Button> ().enabled = true;
            ShopItem2.GetComponent <Button> ().enabled = true;
//			ShopItem3.GetComponent<Button> ().enabled = true;
            buyButton1.GetComponent <Button> ().enabled = true;
            buyButton2.GetComponent <Button> ().enabled = true;
//			buyButton3.GetComponent<Button> ().enabled = true;
            QuestionBox1.SetActive(false);
            QuestionBox2.SetActive(false);
//			QuestionBox3.SetActive (false);
            if (!IsAlreadyOpen)
            {
                PopUpText.text = text;
                PopUpClose.SetActive(true);
                PopUp.SetActive(true);
                IsAlreadyOpen = true;
            }
        }

        if ((Balloon.GetComponent <TalkBalloon> ().NumberOfTalk() >= NeedTalkCount2) && !DialogPanel.activeSelf)
        {
            ShopItem3.GetComponent <Button> ().enabled  = true;
            buyButton3.GetComponent <Button> ().enabled = true;
            QuestionBox3.SetActive(false);
            if (!IsAlreadyOpen2)
            {
                PopUpText.text = text2;
                PopUpClose.SetActive(true);
                PopUp.SetActive(true);
                IsAlreadyOpen2 = true;
            }
        }
        save();
    }
Esempio n. 7
0
    // Use this for initialization

    void Start()
    {
        Balloon.GetComponent <TalkBalloon> ().load();
        load();
    }
Esempio n. 8
0
        public void Update(WorldManager world, DwarfTime time)
        {
            int  hour      = world.Time.CurrentDate.Hour;
            bool shouldEat = TimeDiff(hour, HourOfLastEating) > 12;

            if (_prevHour < 0)
            {
                _prevHour = hour;
            }
            int timeDiff = TimeDiff(hour, _prevHour);

            if (timeDiff > 0)
            {
                _prevHour = hour;
                MaybeDelay(world);
            }
            switch (AdventureState)
            {
            case State.None:
            {
                var balloonPorts = world.PlayerFaction.GetRooms().OfType <BalloonPort>().ToList();
                if (balloonPorts.Count == 0)
                {
                    LastEvent      = "The adventuring party was cancelled, no balloon port.";
                    AdventureState = State.Done;
                    break;
                }
                foreach (var creature in Party)
                {
                    if (!(creature.CurrentTask is GoToZoneTask))
                    {
                        creature.AssignTask(new GoToZoneTask(balloonPorts.First())
                            {
                                Priority = Task.PriorityType.High, Wait = true
                            });
                    }
                }
                AdventureState = State.Starting;
                Vehicle        = EntityFactory.CreateEntity <Balloon>("Balloon", balloonPorts.First().GetBoundingBox().Center() + Vector3.Up * 10);
                Vehicle.GetComponent <BalloonAI>().State = BalloonAI.BalloonState.Waiting;
                Vehicle.GetComponent <BalloonAI>().WaitTimer.Reset();
                break;
            }

            case State.Starting:
            {
                if (Vehicle != null)
                {
                    Vehicle.GetComponent <BalloonAI>().State = BalloonAI.BalloonState.Waiting;
                    Vehicle.GetComponent <BalloonAI>().WaitTimer.Reset();
                }
                var balloonPorts = world.PlayerFaction.GetRooms().OfType <BalloonPort>().ToList();
                if (balloonPorts.Count == 0)
                {
                    LastEvent = "The adventuring party was cancelled, no balloon port.";
                    foreach (var creature in Party)
                    {
                        ReturnCreature(creature);
                        if (creature.CurrentTask is GoToZoneTask)
                        {
                            creature.CancelCurrentTask();
                        }
                    }
                    AdventureState = State.Done;
                    break;
                }
                var port = balloonPorts.First();
                Party.RemoveAll(creature => creature.IsDead);
                if (Party.Count == 0)
                {
                    LastEvent      = "The adventuring party was cancelled, no more members.";
                    AdventureState = State.Done;
                    break;
                }

                bool allOnZone = true;
                foreach (var creature in Party.Where(c => c.Active))
                {
                    if (!port.IsRestingOnZone(creature.Position))
                    {
                        if (!(creature.CurrentTask is GoToZoneTask))
                        {
                            creature.AssignTask(new GoToZoneTask(balloonPorts.First())
                                {
                                    Priority = Task.PriorityType.High, Wait = true
                                });
                        }
                        allOnZone = false;
                        break;
                    }
                    else
                    {
                        DestroyCreature(creature);
                        allOnZone = false;
                    }
                }

                if (allOnZone)
                {
                    Vehicle.GetComponent <BalloonAI>().State = BalloonAI.BalloonState.Leaving;
                    OnStart(world);
                    AdventureState = State.TravelingtoDestination;
                }
                break;
            }

            case State.TravelingtoDestination:
            {
                RemainingTravelTime -= new TimeSpan(0, timeDiff, 0, 0, 0);
                if (shouldEat)
                {
                    Eat(world.Time.CurrentDate);
                    if (AdventureState == State.Done)
                    {
                        break;
                    }
                }

                if (RemainingTravelTime.TotalHours < 1)
                {
                    this.LastEvent = String.Format("The adventuring party has arrived at {0}", DestinationFaction);
                    AdventureState = State.PerformingAction;
                    ActionTimer    = new Timer(ActionTimeMinutes * 60.0f, true);
                    OnArrival(world);
                }

                break;
            }

            case State.PerformingAction:
            {
                ActionTimer.Update(time);
                if (ActionTimer.HasTriggered)
                {
                    OnAction(world);
                    AdventureState      = State.ComingBack;
                    RemainingTravelTime = GetETA(world);
                }
                break;
            }

            case State.ComingBack:
            {
                RemainingTravelTime -= new TimeSpan(0, timeDiff, 0, 0, 0);
                if (shouldEat)
                {
                    Eat(world.Time.CurrentDate);
                    if (AdventureState == State.Done)
                    {
                        break;
                    }
                }
                if (RemainingTravelTime.TotalHours < 1)
                {
                    var     balloonPorts = world.PlayerFaction.GetRooms().OfType <BalloonPort>().ToList();
                    Vector3 location     = world.Camera.Position;
                    if (balloonPorts.Count != 0)
                    {
                        location = balloonPorts.First().GetBoundingBox().Center() + Vector3.Up * 10;
                    }

                    if (Vehicle == null || Vehicle.IsDead)
                    {
                        Vehicle = EntityFactory.CreateEntity <Balloon>("Balloon", location);
                    }
                    Vehicle.GetComponent <BalloonAI>().State = BalloonAI.BalloonState.DeliveringGoods;
                    OnReturn(world);
                    AdventureState = State.Done;
                }
                break;
            }

            case State.Done:
            {
                if (Vehicle != null)
                {
                    Vehicle.GetRoot().Delete();
                }
                break;
            }
            }
        }