Inheritance: MonoBehaviour
Beispiel #1
0
    void OnCollisionEnter(Collision col)
    {
        LiveManager liveManager = col.gameObject.GetComponent <LiveManager> ();

        Debug.Log(liveManager);
        if (liveManager != null)
        {
            liveManager.Health -= damage;
            if (liveManager.Health > 0)
            {
                for (int i = 0; i < liveManager.Renderers.Length / liveManager.Health - 1; i++)
                {
                    liveManager.Renderers [Random.Range(0, liveManager.Renderers.Length)].material.color = startColor;
                }
            }
            else
            {
                for (int i = 0; i < liveManager.Renderers.Length; i++)
                {
                    liveManager.Renderers [i].material.color = startColor;
                }
                GameObject.Find("Text").GetComponent <Text> ().text = owner.name + " gewinnt!";
                GameObject levelReload = Instantiate(levelReloader);
            }
        }
    }
Beispiel #2
0
        public override void LoadContent()
        {
            CurrGame     = (PathDefenceGame)ScreenManager.Game;
            LevelManager = new LevelManager(CurrGame, this, levelName);
            LevelManager.Initialize();
            WaveManager = new WaveManager(CurrGame, this, levelName);
            WaveManager.Initialize();
            Background = new BackgroundGamePlayScreen(CurrGame, levelName);
            Background.Initialize();
            TowerManager = new TowerManager(CurrGame, this);
            TowerManager.Initialize();
            MoneyManager = new MoneyManager(CurrGame, this);
            MoneyManager.Initialize();
            LiveManager = new LiveManager(CurrGame, this);
            LiveManager.Initialize();
            PointsManager = new PointsManager();
            PointsManager.Initialize();

            GuiManager = new GuiManager(CurrGame, this);
            GuiManager.Initialize();
            CreepDeleteList.AddRange(CreepList);

            AddCreepList.Clear();

            CreepTimer.Start();

            gameState = EGameState.Running;
            CurrGame.IsMouseVisible = true;
            base.LoadContent();
        }
 void Start()
 {
     if (LM == null)
     {
         LM = GameObject.FindGameObjectWithTag("LM").GetComponent <LiveManager>();
     }
 }
Beispiel #4
0
    public void RespawnPlayer()
    {
        LiveManager.leavelive();
        Debug.Log("Player Respawn");

        //AudioSource aus = new AudioSource();
        //aus.PlayOneShot(playerdeath);
        player.transform.position = currentCheckpoint.transform.position;
    }
Beispiel #5
0
 void Start()
 {
     Cursor.visible    = false;
     activeSpecialKeys = false;
     Cursor.lockState  = CursorLockMode.Locked;
     speed             = defaultSpeed;
     rb                   = GetComponent <Rigidbody> ();
     startPosition        = transform.position;
     liveManager          = GetComponent <LiveManager> ();
     liveManager.onDeath += die;
 }
Beispiel #6
0
        }   // end of MainMenu c'tor

        private void ActivateMainMenu()
        {
            // Backing out to main menu kills the session we're in.
            // If we're the host, everyone is disconnected.
            LiveManager.CloseSession();

            // Cancel pending profile updates, joinable session finds, etc.
            LiveManager.ClearQueuedOperations(this);

            // Activate main menu.
            Deactivate();
            BokuGame.bokuGame.mainMenu.Activate();
        }
 private void CheckAttack()
 {
     Collider2D[] enemigos = Physics2D.OverlapCircleAll(attackChecker.position, radiusAttackCheck, enemigoLayer);
     if (enemigos.Length != 0)
     {
         foreach (Collider2D enemigo in enemigos)
         {
             LiveManager vida = enemigo.GetComponent <LiveManager>();
             vida.reducirVida(10);
         }
         CameraShakeCM.Temblor(.5f, 2, .2f);
     }
 }
 public DynamicModuleConfigurationManager(
     IHostingEnvironment hostingEnvironment,
     LiveManager liveManager,
     DynamicModuleManager dynamicModuleManager,
     DynamicModuleProvider dynamicModuleProvider,
     DynamicModuleConfiguration dynamicModuleConfiguration
     )
 {
     m_contentRootPath            = hostingEnvironment.ContentRootPath;
     m_liveManager                = liveManager;
     m_dynamicModuleManager       = dynamicModuleManager;
     m_dynamicModuleProvider      = dynamicModuleProvider;
     m_dynamicModuleConfiguration = dynamicModuleConfiguration;
 }
Beispiel #9
0
        public override void Activate()
        {
            if (state != States.Active)
            {
                LiveManager.CloseSession();

                // Do stack handling here.  If we do it in the update object we have no
                // clue which order things get pushed and popped and madness ensues.
                CommandStack.Push(commandMap);

                pendingState             = States.Active;
                BokuGame.objectListDirty = true;

                DeactivateMessages();
            }
        }
Beispiel #10
0
    void Awake()
    {
        //Check if instance already exists
        if (instance == null)
        {
            //if not, set instance to this
            instance = this;
        }

        //If instance already exists and it's not this:
        else if (instance != this)
        {
            //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager.
            Destroy(gameObject);
        }
        maxLives = 5f;
    }
Beispiel #11
0
            internal void Deactivate()
            {
                LiveManager.FriendUpdatesEnabled   = false;
                LiveManager.JoinableUpdatesEnabled = false;

                if (LiveManager.IsConnected)
                {
                    LiveManager.Session.GamerJoined -= Session_GamerJoined;
                    LiveManager.Session.GamerLeft   -= Session_GamerLeft;
                }

                LiveManager.ClearQueuedOperations(null);

                grid.Active = false;

                // We rebuild the grid each time the share hub is activated, to reflect the dynamic nature of the friend list.
                BokuGame.Unload(grid);
                grid.Clear();

                elements.Clear();
            }
Beispiel #12
0
        private void StartJumpingIn(string gamerTag, object param)
        {
            // Turn off background updates to friend profiles.
            LiveManager.FriendUpdatesEnabled = false;
            // Turn off background updates to friend joinable states.
            LiveManager.JoinableUpdatesEnabled = false;

            // TODO: Warn of potentially "destructive" action. Player may have invited people to join their session.
            // This action closes the local session, invalidating the invites.
            LiveManager.CloseSession();

            // Cancel pending friend profile and joinable state queries.
            LiveManager.ClearQueuedOperations(null);

            // Show the "initializing sharing room" notification dialog.
            openingSharingRoomMessage.Activate();

            // Start finding our friend's network session.
            SessionFinder finderOp = new SessionFinder(gamerTag, FindSessionComplete_Join, param, this);

            finderOp.Queue();
        }
Beispiel #13
0
        public void OnSelect(UIGrid grid)
        {
            // User selected a friend.

            grid.Active = true;

            int index = shared.grid.SelectionIndex.Y;

            UIGridShareFriendElement friendElement = shared.grid.Get(0, index) as UIGridShareFriendElement;

            UIGridSharingServerElement serverElement = shared.grid.Get(0, index) as UIGridSharingServerElement;

            if (friendElement != null)
            {
                if (friendElement.Friend.IsOnline)
                {
                    if (friendElement.Friend.InvitedUs || friendElement.Friend.IsJoinable)
                    {
                        // Friend has a joinable session, directly join it ("jump in").
                        StartJumpingIn(friendElement.Friend.GamerTag, friendElement);

                        // Don't allow the user to interact with the share hub while the SessionFinder is running.
                        grid.Active = false;
                    }
                    else if (friendElement.Friend.IsJoined && LiveManager.IsConnected)
                    {
                        // Selected friend has joined our session, just go to the sharing room.

                        ActivateSharingScreen();

                        grid.Active = false;
                    }
                    else if (!friendElement.Friend.InvitedThem)
                    {
                        // Start sending an invitation to this friend.

                        friendElement.Friend.InvitingThem = true;

                        if (!LiveManager.IsConnected)
                        {
                            openingInviteGuideMessage.Activate();

                            LiveManager.ClearQueuedOperations(null);

                            // We must have a session open before we can send an invite.
                            // Start creating the network session.
                            SessionCreator createOp = new SessionCreator(SessionCreatorComplete_StartInvitingFriend, friendElement, this);
                            createOp.Queue();
                        }
                        else
                        {
                            // Session is already open, no need to create it before sending the invite.
                            StartInvitingFriend(friendElement);
                        }
                    }
                }
            }
            else if (serverElement != null)
            {
                if (serverElement.IsOnline)
                {
                    StartJumpingIn(serverElement.GamerTag, serverElement);

                    // Don't allow the user to interact with the share hub while the SessionFinder is running.
                    grid.Active = false;
                }
            }
        }
Beispiel #14
0
            public override void Update()
            {
                if (UpdateMessages())
                {
                    return;
                }

                // If we signed out of LIVE, back out to the main menu.
                if (!GamerServices.SignedInToLive)
                {
                    parent.ActivateMainMenu();
                    return;
                }

                // If we are joining a share session by accepting an invite from the Dashboard, bail now; we're just waiting for this
                // operation to complete then we'll open the sharing screen.
                if (LiveManager.JoiningShareInvitation)
                {
                    return;
                }

                // If we are accepting an invite via the Guide interface, start joining the session.
                if (LiveManager.AcceptedShareInvitation)
                {
                    parent.openingSharingRoomMessage.Activate();

                    // Change state from "accepting" to "joining" the invited session.
                    LiveManager.AcceptedShareInvitation = false;
                    LiveManager.JoiningShareInvitation  = true;

                    // Disable the share hub UI.
                    shared.grid.Active = false;

                    // Cancel pending LIVE queries.
                    LiveManager.ClearQueuedOperations(null);

                    // Start joining the invited session.
                    InvitedSessionJoiner joinerOp = new InvitedSessionJoiner(parent.JoinSessionComplete_ActivateSharingScreen, null, parent);
                    joinerOp.Queue();

                    return;
                }

                // Don't do any input processing if the guide is up.
                if (GamerServices.IsGuideVisible)
                {
                    return;
                }

                // Check for mouse press on bottom tile.
                // hit is in pixels in screen coords (before overscan adjustment)
                Vector2 hit = MouseInput.GetAspectRatioAdjustedPosition(shared.camera, true);

                bool openPressed = false;

                if (shared.openBox.LeftPressed(hit))
                {
                    openPressed = true;
                }

                GamePadInput pad = GamePadInput.GetGamePad0();

                if (Actions.StartSharing.WasPressed || openPressed || shared.forceSessionRestart)
                {
                    Actions.StartSharing.ClearAllWasPressedState();

                    shared.forceSessionRestart = false;

                    // User selected "Enter Sharing Room"
                    if (!LiveManager.IsConnected)
                    {
                        LiveManager.FriendUpdatesEnabled   = false;
                        LiveManager.JoinableUpdatesEnabled = false;

                        parent.openingSharingRoomMessage.Activate();

                        LiveManager.ClearQueuedOperations(null);

                        SessionCreator createOp = new SessionCreator(parent.SessionCreatorComplete_ActivateSharingScreen, null, this);
                        createOp.Queue();
                    }
                    else
                    {
                        parent.ActivateSharingScreen();
                    }
                }

                // If we're still active, ensure that the friends list is up to date.
                // We don't want to do this if not active since we'll just end up
                // adding all our friends to the grid which we just cleared...
                if (shared.grid.Active)
                {
                    // We're not accepting or joining an invited session, and we're still logged in to LIVE, so update the friend menu to reflect their current status bits.
                    List <LiveFriend> friends = LiveManager.Friends;

                    bool refreshGrid = false;

                    foreach (LiveFriend friend in friends)
                    {
                        UIGridShareFriendElement elem = shared.FindFriendElement(friend.GamerTag);

                        // Build the menu on the fly.
                        if (elem == null && friend.IsFriend)
                        {
                            elem = new UIGridShareFriendElement(friend);
                            shared.elements.Add(elem);
                            refreshGrid = true;
                        }
                        else if (elem != null && !friend.IsFriend)
                        {
                            shared.elements.Remove(elem);
                            refreshGrid = true;
                        }
                    }

                    // If we've changed the list, call update on the grid again so
                    // that it's in a good state for rendering.
                    if (refreshGrid)
                    {
                        shared.RefreshGrid();
                    }
                }

                Matrix parentMatrix = Matrix.Identity;

                shared.grid.Update(ref parentMatrix);

                // Only care about mouse input on the grid if the grid is not empty.
                if (shared.grid.ActualDimensions != Point.Zero)
                {
                    // Mouse Input.
                    // Scroll wheel is handled by the grid.
                    // Clicking on Invite square should send invite.
                    // Clicking on user tile should bring that user into focus.

                    // Check if mouse hitting current selection object.
                    UIGridElement e     = shared.grid.SelectionElement;
                    Matrix        mat   = Matrix.Invert(e.WorldMatrix);
                    Vector2       hitUV = MouseInput.GetHitUV(shared.camera, ref mat, e.Size.X, e.Size.Y, true);

                    bool focusElementHit = false;
                    if (hitUV.X >= 0 && hitUV.X < 1.25 && hitUV.Y >= 0 && hitUV.Y < 1)
                    {
                        focusElementHit = true;

                        // See if we hit the "invite/join" tile which is
                        // to the right of the main part of the tile.
                        if (hitUV.X > 1)
                        {
                            if (MouseInput.Left.WasPressed)
                            {
                                MouseInput.ClickedOnObject = this;
                            }
                            if (MouseInput.Left.WasReleased && MouseInput.ClickedOnObject == this)
                            {
                                parent.OnSelect(shared.grid);
                            }
                        }
                    }

                    // If we didn't hit the focus object, see if we hit any of the others.
                    // If so, bring them into focus.
                    if (!focusElementHit && MouseInput.Left.WasPressed)
                    {
                        for (int i = 0; i < shared.grid.ActualDimensions.Y; i++)
                        {
                            if (i == shared.grid.SelectionIndex.Y)
                            {
                                continue;
                            }

                            e     = shared.grid.Get(0, i);
                            mat   = Matrix.Invert(e.WorldMatrix);
                            hitUV = MouseInput.GetHitUV(shared.camera, ref mat, e.Size.X, e.Size.Y, true);

                            if (hitUV.X >= 0 && hitUV.X < 1 && hitUV.Y >= 0 && hitUV.Y < 1)
                            {
                                // We hit an element, so bring it into focus.
                                shared.grid.SelectionIndex = new Point(0, i);

                                break;
                            }
                        }
                    }
                }
            }   // end of Update()
 private void Reset()
 {
     liveManager = GetComponent <LiveManager>();
 }
Beispiel #16
0
        private void FindSessionComplete_Join(AsyncLiveOperation op)
        {
            UIGridShareFriendElement friendElement = op.Param as UIGridShareFriendElement;

            if (op.Succeeded)
            {
                SessionFinder finderOp = op as SessionFinder;

                if (finderOp.AvailableSessions.Count > 0)
                {
                    // We found an available session. Before we can start joining it, we must cancel all pending LIVE
                    // operations. Some of them may be queued attempts to find joinable sessions (incompatible with
                    // joining a session), and the others will be profile updates (no longer relevant as we're leaving
                    // this screen).
                    LiveManager.ClearQueuedOperations(null);

                    openingSharingRoomMessage.Activate();

                    // Start joining the session.
                    AvailableSessionJoiner joinerOp = new AvailableSessionJoiner(finderOp.AvailableSessions[0], JoinSessionComplete_ActivateSharingScreen, op.Param, this);

                    // This operation must start before the network session updates again or
                    // the available sessions collection becomes invalid for some reason.
                    joinerOp.Queue(true);

                    finderOp.AvailableSessions = null;  // prevent dispose, since we passed the available session to the joiner.

                    // TODO: Show joining session message here..
                }
                else
                {
                    // We didn't find the session. Re-enable the share hub's periodic LIVE operations.
                    LiveManager.FriendUpdatesEnabled   = true;
                    LiveManager.JoinableUpdatesEnabled = true;

                    // Session is no longer available, so mark friend as not joinable.
                    // This may change if we detect they are joinable again.
                    if (friendElement != null)
                    {
                        friendElement.Friend.IsJoinable = false;
                    }

                    // Not leaving the share hub anymore, since we failed to join the session.
                    shared.grid.Active = true;
                    openingSharingRoomMessage.Deactivate();
                }
            }
            else
            {
                // We didn't find the session. Re-enable the share hub's periodic LIVE operations.
                LiveManager.FriendUpdatesEnabled   = true;
                LiveManager.JoinableUpdatesEnabled = true;

                // The join operation failed, so mark friend as not joinable.
                // This may change if we detect they are joinable again.
                if (friendElement != null)
                {
                    friendElement.Friend.IsJoinable = false;
                }

                // Not leaving the share hub anymore, since we failed to join the session.
                shared.grid.Active = true;
                openingSharingRoomMessage.Deactivate();
            }
        }
 private void Awake()
 {
     Instance = this;
 }
Beispiel #18
0
 void Update()
 {
     if (LightControllor.isNight())
     {
         float enemyRatial = Random.Range(0f, 1f);
         if (Enemies.Count < Const.numEnemy && Random.Range(0, 1f) > 0.7f)
         {
             pushNewEnemy(getEnemyIdByRatial(enemyRatial));
         }
         for (int i = 0; i < Enemies.Count; i++)
         {
             // Auto move toward main actor
             float            enemyDis     = calDistanceWithMainActor(Enemies[i]);
             Const.GameItemID monsterId    = ItemMap.getItemsID(Enemies[i].name);
             Creature         creatureInfo = ItemMap.getCreatureInfo(monsterId);
             if (enemyDis < creatureInfo.attackDistance)
             {
                 if (!clickEvent.modestate)
                 {
                     mainActor.GetComponent <LiveManager>().attack(creatureInfo.attackPower);
                 }
                 if (monsterId == Const.GameItemID.Slime)
                 {
                     BoxCollider col  = Enemies[i].GetComponent <BoxCollider>();
                     SlimeWeapon weap = Enemies[i].GetComponent <SlimeWeapon>();
                     Rigidbody   rig  = Enemies[i].GetComponent <Rigidbody>();
                     Enemies[i].transform.localScale = new Vector3(7, 7, 7);
                     col.isTrigger  = true;
                     weap.triggered = true;
                     rig.useGravity = false;
                 }
             }
             else if (enemyDis < creatureInfo.trackDistance)
             {
                 Enemies[i].GetComponent <AutoMove>().setTarget(mainActor.transform.position);
             }
             // Play audio
             AudioSource audio = Enemies[i].GetComponent <AudioSource>();
             if (enemyDis < creatureInfo.audioDistance)
             {
                 if (!audio.isPlaying)
                 {
                     audio.Play(0);
                 }
                 audio.volume = 1 - enemyDis / creatureInfo.audioDistance;
             }
             else
             {
                 audio.Pause();
             }
             // Destroy the creature if they died
             LiveManager monster = Enemies[i].GetComponent <LiveManager>();
             if (monster.live <= 0)
             {
                 Destroy(Enemies[i].gameObject);
                 Enemies.RemoveAt(i);
             }
         }
     }
     else if (Random.Range(0f, 1f) > 0.7)
     {
         int lastIndex = Enemies.Count;
         if (lastIndex > 0)
         {
             Destroy(Enemies[lastIndex - 1].gameObject);
             Enemies.RemoveAt(lastIndex - 1);
         }
     }
 }