Esempio n. 1
0
	public void Spawn(Vector3 trapPos, Vector3 leverPos) {
		GameStateManager gs = GameObject.Find ("GameState").GetComponent<GameStateManager> ();
		MapGen mg = GameObject.Find ("TileGenParent").GetComponent<MapGen> ();

		int layerMask = 1 << LayerMask.NameToLayer ("Default");
		RaycastHit2D hit = Physics2D.Raycast (trapPos, Vector2.up, Mathf.Infinity, layerMask);

		GameObject trap = gs.CreateOverNetworkInstant (trapPrefab, trapPos);
		SpringJoint2D joint = trap.GetComponent<SpringJoint2D> ();
		Rigidbody2D trapBody = trap.GetComponent<Rigidbody2D> ();

		Rigidbody2D colliderRigidbody = hit.collider.gameObject.AddComponent<Rigidbody2D> ();
		joint.connectedBody = colliderRigidbody;
		joint.connectedAnchor = joint.connectedBody.transform.InverseTransformPoint (hit.point);
		colliderRigidbody.constraints = RigidbodyConstraints2D.FreezeAll;

		GameObject lever = gs.CreateOverNetworkInstant (leverPrefab, leverPos);
		TrapDeployer deployer = lever.GetComponent<TrapDeployer> ();
		deployer.droppingTrap = trap;
		deployer.raisingTrap = trap;

		MapGen.Room room = mg.GetRandomRoom ();
		float deltaX = Random.value * mg.roomWidth;
		float deltaY = Random.value * mg.roomHeight;
		Vector2 pos = new Vector2 (room.x + deltaX, room.y - deltaY);

		GameObject enemy = gs.CreateOverNetworkInstant (enemyPrefab, pos);

	 	tm = trap.GetComponent<TrapManager> ();
		tm.AddTarget(enemy, ((manager) => {
			Debug.Log("Captured enemy");
			GameObject.Find("GameState").GetComponent<GameStateManager>().ResetGame();
			return true;
		}));
	}
Esempio n. 2
0
 void Awake()
 {
     enemymanager = GetComponent<EnemyManager>();
     playermanager = GetComponent<PlayerManager>();
     trapmanager = GetComponent<TrapManager>();
     msgcenter = GetComponent<NetworkMsgSendCenter>();
 }
Esempio n. 3
0
    public virtual void Move(Cell destinationCell, List <Cell> path, TrapManager trapmanager)
    {
        if (isMoving)
        {
            return;
        }

        var totalMovementCost = path.Sum(h => h.MovementCost);

        if (MovementPoints < totalMovementCost)
        {
            return;
        }

        MovementPoints -= totalMovementCost;

        Cell.IsTaken  = false;
        Cell.Occupent = null;
        bool        trapfound = false;
        List <Cell> TrapPath  = new List <Cell>();

        foreach (Cell c in path)
        {
            if (!trapfound)
            {
                TrapPath.Add(c);
            }
            if (trapmanager.findTrap(c))
            {
                trapmanager.Trigger(this);
                trapfound = true;
            }
        }
        TrapPath.Reverse();
        Cell = destinationCell;
        destinationCell.IsTaken  = true;
        destinationCell.Occupent = this;

        if (MovementSpeed > 0 && trapfound)
        {
            StartCoroutine(MovementAnimation(TrapPath));
        }
        else if (MovementSpeed > 0 && !trapfound)
        {
            StartCoroutine(MovementAnimation(path));
        }
        else
        {
            transform.position = Cell.transform.position;
        }

        if (UnitMoved != null && trapfound)
        {
            UnitMoved.Invoke(this, new MovementEventArgs(Cell, destinationCell, TrapPath));
        }
        else if (UnitMoved != null && !trapfound)
        {
            UnitMoved.Invoke(this, new MovementEventArgs(Cell, destinationCell, path));
        }
    }
Esempio n. 4
0
    private void CreateTrap(IEntityDataStruct entityDataStruct)
    {
        SMsgPropCreateEntity_SC_Trap sMsgPropCreateEntity_SC_Trap = (SMsgPropCreateEntity_SC_Trap)entityDataStruct;
        string trapName   = "bushoujia";
        var    trapPrefab = this.FindByName(trapName);

        //var trapPrefab = EctypeConfigManager.Instance.TrapConfigList[sMsgPropCreateEntity_SC_Trap.BaseValue.OBJECT_FIELD_ENTRY_ID]._TrapPrefab;

        var pos = Vector3.zero;

        pos = pos.GetFromServer(sMsgPropCreateEntity_SC_Trap.TrapX, sMsgPropCreateEntity_SC_Trap.TrapY);
        //var pos = new Vector3(120, 0, -100);
        ////TraceUtil.Log("创建TrapID=====>>>>" + sMsgPropCreateEntity_SC_Trap.SMsg_Header.uidEntity);

        var trap          = (GameObject)GameObject.Instantiate(trapPrefab, pos, Quaternion.identity);
        var trapBehaviour = trap.GetComponent <TrapBehaviour>();

        trapBehaviour.TrapDataModel = sMsgPropCreateEntity_SC_Trap;

        EntityModel trapDataModel = new EntityModel();

        trapDataModel.GO               = trap;
        trapDataModel.Behaviour        = trapBehaviour;
        trapDataModel.EntityDataStruct = sMsgPropCreateEntity_SC_Trap;

        TrapManager.GetInstance();
        EntityController.Instance.RegisteEntity(sMsgPropCreateEntity_SC_Trap.SMsg_Header.uidEntity, trapDataModel);
    }
Esempio n. 5
0
 void StartUp()
 {
     DontDestroyOnLoad(this);
     UIM = GameObject.Find("UIManager").GetComponent<UIManager>();
     TrapM = GameObject.Find("TrapManager").GetComponent<TrapManager>();
     money = startingMoney;
     UIM.UpdateMoneyText();
 }
Esempio n. 6
0
    private void Awake()
    {
        m_PlayerManager = PlayerManager.Instance;
        m_EnemyManager  = EnemyManager.Instance;
        m_TrapManager   = TrapManager.Instance;

        m_UIManager = UIManager.Instance;
    }
Esempio n. 7
0
 void StartUp()
 {
     DontDestroyOnLoad(this);
     UIM   = GameObject.Find("UIManager").GetComponent <UIManager>();
     TrapM = GameObject.Find("TrapManager").GetComponent <TrapManager>();
     money = startingMoney;
     UIM.UpdateMoneyText();
 }
Esempio n. 8
0
    private void Awake()
    {
        s_singleton            = this;
        m_ejectionTraps        = new List <EjectionTrap>();
        m_ejectionTrapsTileIDs = new Dictionary <EjectionTrap, int>();

        m_inversionTraps        = new List <InversionTrap>();
        m_inversionTrapsTileIDs = new Dictionary <InversionTrap, int>();
    }
Esempio n. 9
0
    // Use this for initialization
    void Start()
    {
        _player   = GameObject.Find("Player").GetComponent <Player>();
        _trap     = GetComponent <TrapManager>();
        _pathInfo = GetComponent <ShowPath>();

        GameTimer  = (int)(_pathInfo.GetCorrectTilesCount() * 3.5f);
        GameTimer -= 0.01f;
    }
Esempio n. 10
0
    void Start()
    {
        m_theghosts   = GameObject.FindObjectsOfType <TrapPlayerController>();
        m_trapmanager = GameObject.FindObjectOfType <TrapManager>();

        Debug.Log(m_trapplayerindex);
        m_theghosts[m_trapplayerindex].m_selectedtrap = m_trapplayerindex;
        m_trapmanager.GetTrap(m_selectedtrap).UseThisTrap(true);
    }
Esempio n. 11
0
 void Awake()
 {
     //if (!gm) gm = GameObject.Find("GameManager").GetComponent<GameManager>();
     if (!tm)
     {
         tm = GameObject.Find("TrapManager").GetComponent <TrapManager>();
     }
     remaining = GetComponentInChildren <Text>();
 }
    ///////////////////////////////////////////////////////////////////////////

    public static TrapManager Get()
    {
        if (!s_Instance)
        {
            s_Instance = GameObject.FindObjectOfType <TrapManager>();
            s_Instance.ReInit();
        }

        return(s_Instance);
    }
Esempio n. 13
0
 public void Awake()
 {
     if (_instance == null)
     {
         _instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
    ///////////////////////////////////////////////////////////////////////////

    public void UpdateHighlightedObject()
    {
        GameObject newHighlightObject = null;

        Vector2 selfPos = transform.position.xz();
        Vector2 lookDir = transform.forward.xz();

        lookDir.Normalize();
        Trap nearestTrap = TrapManager.Get().GetNearestTrap(true, EquippedTool, selfPos, true, true, lookDir);

        if (nearestTrap)
        {
            newHighlightObject = nearestTrap.gameObject;
        }
        else
        {
            Tool nearestTool = ToolTrolley.Get().GetNearestTool(selfPos, true, lookDir);
            if (nearestTool)
            {
                newHighlightObject = nearestTool.gameObject;
            }
        }

        if (newHighlightObject != HighlightedObject)
        {
            if (HighlightedObjectIcon)
            {
                GameObject.Destroy(HighlightedObjectIcon);
            }

            if (newHighlightObject)
            {
                // highlight new
                HighlightedObjectIcon = WorldSpaceCanvas.Get().CreateInteractIcon(GetPlayerColor(Slot));
            }

            HighlightedObject = newHighlightObject;
        }

        if (HighlightedObject && HighlightedObjectIcon)
        {
            if (!EquippedTool || HighlightedObject != EquippedTool.gameObject)
            {
                float offset = HighlightedObject.gameObject.GetComponent <Tool>() ? 0.8f : 2.0f;
                HighlightedObjectIcon.transform.position = HighlightedObject.transform.position + Vector3.up * offset;

                Vector3 offsetTowardsCamera = (Camera.main.transform.position - HighlightedObject.transform.position);
                offsetTowardsCamera.Normalize();

                HighlightedObjectIcon.transform.position += offsetTowardsCamera * 2.0f;
            }
        }
    }
Esempio n. 15
0
 private void Awake()
 {
     // Singleton
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(this);
     }
 }
Esempio n. 16
0
    public override void PreInitialize()
    {
        base.PreInitialize();
        this.placingObjectManager = PlacingObjectManager.Instance;
        this.gridManager          = GridManager.Instance;
        this.towerManager         = TowerManager.Instance;
        this.trapManager          = TrapManager.Instance;
        this.timeManager          = TimeManager.Instance;
        this.gameVariables        = GameVariables.instance;
        this.mapInfoPck           = MapInfoPck.Instance;

        this.placingObjectManager.PreInitialize();
    }
Esempio n. 17
0
    ///////////////////////////////////////////////////////////////////////////

    public void Interact()
    {
        if (m_State == TrapState.Broken_WaitForFix || m_State == TrapState.Warning)
        {
            ChangeToState(TrapState.WaitingForAttack);
            Debug.Log("Fixed " + gameObject.name.AddBrackets());
            if (DestroyOnFix)
            {
                TrapManager.Get().m_Traps.Remove(this);
                Destroy(this.gameObject, 1);
            }
        }
    }
Esempio n. 18
0
    private void Awake()
    {
        m_TileManager   = TileManager.Instance;
        m_PlayerManager = PlayerManager.Instance;
        m_EnemyManager  = EnemyManager.Instance;
        m_TrapManager   = TrapManager.Instance;
        m_LogManager    = LogManager.Instance;
        m_UIManager     = UIManager.Instance;
        m_TunrManager   = TurnManager.Instance;

        m_Astar         = Astar.Instance;
        m_BattleManager = BattleManager.Instance;
    }
Esempio n. 19
0
    private void Initialize()
    {
        _dungeonCreator   = GameObject.Find("Managers/DungeonCreator").GetComponent <DungeonCreator>();
        _cameraController = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <MainCamController>();
        _monsterManager   = GameObject.Find("Managers/MonsterManager").GetComponent <MonsterManager>();
        _trapManager      = GameObject.Find("Managers/TrapManager").GetComponent <TrapManager>();
        _uiManager        = GameObject.Find("Managers/UIManager").GetComponent <UIManager>();
        _mapManager       = GameObject.Find("Managers/MapManager").GetComponent <MapManager>();
        _itemManager      = GameObject.Find("Managers/ItemManager").GetComponent <ItemManager>();
        _heroManager      = GameObject.Find("Managers/HeroManager").GetComponent <HeroManager>();

        Mode = GameMode.ROGUE_LIKE;
    }
Esempio n. 20
0
        public void OnClientFinish(Client client)
        {
            Client outClient;

            while (!Clients.TryRemove(client.PlayerId, out outClient))
            {
                Thread.Sleep(1);
            }

            Send(new NetworkPacketRemovePlayer(client.PlayerId), client);

            MushroomAI.OnClientFinish(client);
            PigAI.OnClientFinish(client);
            TrapManager.OnClientFinish(this, client);
        }
Esempio n. 21
0
    //static Action<Trap> TakeEffect = TrapEffect;

    //private Dictionary<Trap, Action<Trap>> TrapsToActions = new Dictionary<Trap, Action<Trap>>();

    // Start is called before the first frame update
    void Start()
    {
        bull = GameObject.Find("Bull");
        // If there is no Instance, makes this the Instance
        if (Instance == null)
        {
            DontDestroyOnLoad(gameObject);
            Instance = this;
        }

        // If an instance already exists, destroy this
        else if (Instance != this)
        {
            Destroy(gameObject);
        }
    }
Esempio n. 22
0
    // Use this for initialization
    void Awake()
    {
        if (!gm)
        {
            gm = GameObject.Find("GameManager").GetComponent <GameManager>();
        }
        if (!tm)
        {
            tm = GameObject.Find("TrapManager").GetComponent <TrapManager>();
        }

        rend         = GetComponent <SpriteRenderer>();
        rend.enabled = false;

        trap = null;
    }
Esempio n. 23
0
    public virtual void Dash(Cell destinationCell, List <Cell> path, TrapManager trapmanager)
    {
        Cell.IsTaken  = false;
        Cell.Occupent = null;
        bool        trapfound = false;
        List <Cell> TrapPath  = new List <Cell>();

        foreach (Cell c in path)
        {
            if (!trapfound)
            {
                TrapPath.Add(c);
            }
            if (trapmanager.findTrap(c))
            {
                trapmanager.Trigger(this);
                trapfound = true;
            }
        }
        TrapPath.Reverse();
        Cell          = destinationCell;
        Cell.IsTaken  = true;
        Cell.Occupent = this;

        if (MovementSpeed > 0 && trapfound)
        {
            StartCoroutine(RunAnimation(TrapPath));
        }
        else if (MovementSpeed > 0 && !trapfound)
        {
            StartCoroutine(RunAnimation(path));
        }
        else
        {
            transform.position = Cell.transform.position;
        }

        if (UnitMoved != null && trapfound)
        {
            UnitMoved.Invoke(this, new MovementEventArgs(Cell, destinationCell, TrapPath));
        }
        else if (UnitMoved != null && !trapfound)
        {
            UnitMoved.Invoke(this, new MovementEventArgs(Cell, destinationCell, path));
        }
    }
Esempio n. 24
0
    // Update is called once per frame
    //	void Update () {
    //
    //	}

    void OnCollisionEnter2D(Collision2D collision)
    {
        Collider2D other = collision.collider;

        Debug.Log("Entered trigger on trap deployer");
        if (other.tag == "Player")
        {
            if (droppingTrap)
            {
                TrapManager manager = droppingTrap.GetComponent <TrapManager> ();
                manager.DropTrap();
            }
            if (raisingTrap)
            {
                TrapManager manager = raisingTrap.GetComponent <TrapManager> ();
                manager.RaiseTrap();
            }
        }
    }
    public void Update()
    {
        if (!hasAuthority)
        {
            return;
        }

        // Lancer de bière
        if (Input.GetMouseButton(0))
        {
            ThrowBeer();
        }

        // Activation des trappes
        if (m_closeToTrapTrigger && Input.GetButtonDown("Interaction"))
        {
            TrapManager.TriggerTraps();
        }
    }
 private void Start()
 {
     Poutch = GameObject.FindGameObjectWithTag("Beast");
     while (Poutch.transform.parent != null)
     {
         Poutch = Poutch.transform.parent.gameObject;
     }
     pc    = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();
     timer = -1f;
     Pm    = GameObject.FindGameObjectWithTag("GameManager").GetComponent <PanelManager>();
     Tm    = Pm.GetComponent <TrapManager>();
     Sm    = Poutch.GetComponent <SummonMini>();
     StartTimer(me.me.entryLine);
     ResetSpeak();
     attackTimer = me.me.cooldown;
     ResetCooldown();
     if (me.me.classe == Character.Classe.Clone)
     {
         cooldownPanel.gameObject.SetActive(false);
     }
     speTimer = -1.5f;
 }
Esempio n. 27
0
    public void ShowPlayScene()
    {
        m_playScene.SetActive(true);
        m_lobbyScene.SetActive(false);

        m_playersCameras.SetActive(NetworkClient.active);
        foreach (Camera camera in m_serverCameras)
        {
            camera.gameObject.SetActive(NetworkServer.active);
        }
        ClientUI.ShowClientUI(NetworkClient.active);
        SnooperUI.ShowSnooperPlayUI(NetworkClient.active);

        if (NetworkServer.active)
        {
            m_lobbyDiscovery.StopBroadcast();
            ServerUI.ShowServerUI(true);
            RoundManager.StartRound();
            TrapManager.StartSpawningTrap();
            GalaxyAudioPlayer.PlayMainAmbiance();
        }
    }
Esempio n. 28
0
    private void OnTriggerEnter(Collider other)
    {
        Snooper trapedSnooper = other.GetComponent <Snooper>();

        if (trapedSnooper == null)
        {
            return;
        }

        if (trapedSnooper.isJumping)
        {
            return;
        }

        m_audioSource.PlayOneShot(m_triggerSound);

        m_particuleOnTrigger.gameObject.SetActive(true);
        m_particuleOnTrigger.Play();
        if (NetworkServer.active)
        {
            TrapManager.RemoveTrap(this);
            if (trapedSnooper.isHuman)
            {
                Team.humanTeam.IncreaseTrapsTakenCount();
            }
            else
            {
                Team.robotTeam.IncreaseTrapsTakenCount();
            }
        }

        if (!trapedSnooper.hasAuthority)
        {
            return;
        }

        OnTrapTriggered(other, trapedSnooper);
    }
Esempio n. 29
0
    public void Spawn(Vector3 trapPos, Vector3 leverPos)
    {
        GameStateManager gs = GameObject.Find("GameState").GetComponent <GameStateManager> ();
        MapGen           mg = GameObject.Find("TileGenParent").GetComponent <MapGen> ();

        int          layerMask = 1 << LayerMask.NameToLayer("Default");
        RaycastHit2D hit       = Physics2D.Raycast(trapPos, Vector2.up, Mathf.Infinity, layerMask);

        GameObject    trap     = gs.CreateOverNetworkInstant(trapPrefab, trapPos);
        SpringJoint2D joint    = trap.GetComponent <SpringJoint2D> ();
        Rigidbody2D   trapBody = trap.GetComponent <Rigidbody2D> ();

        Rigidbody2D colliderRigidbody = hit.collider.gameObject.AddComponent <Rigidbody2D> ();

        joint.connectedBody           = colliderRigidbody;
        joint.connectedAnchor         = joint.connectedBody.transform.InverseTransformPoint(hit.point);
        colliderRigidbody.constraints = RigidbodyConstraints2D.FreezeAll;

        GameObject   lever    = gs.CreateOverNetworkInstant(leverPrefab, leverPos);
        TrapDeployer deployer = lever.GetComponent <TrapDeployer> ();

        deployer.droppingTrap = trap;
        deployer.raisingTrap  = trap;

        MapGen.Room room   = mg.GetRandomRoom();
        float       deltaX = Random.value * mg.roomWidth;
        float       deltaY = Random.value * mg.roomHeight;
        Vector2     pos    = new Vector2(room.x + deltaX, room.y - deltaY);

        GameObject enemy = gs.CreateOverNetworkInstant(enemyPrefab, pos);

        tm = trap.GetComponent <TrapManager> ();
        tm.AddTarget(enemy, ((manager) => {
            Debug.Log("Captured enemy");
            GameObject.Find("GameState").GetComponent <GameStateManager>().ResetGame();
            return(true);
        }));
    }
Esempio n. 30
0
 public void Awake()
 {
     m_instance = this;
 }
Esempio n. 31
0
 public void Start()
 {
     s_singleton          = this;
     m_leftLeverAnimator  = m_leftTrigger.GetComponent <Animator>();
     m_rightLeverAnimator = m_rightTrigger.GetComponent <Animator>();
 }
Esempio n. 32
0
    // Use this for initialization
    void Start()
    {
        score = 0;

        if (!player)
        {
            player = GameObject.Find("Player");
        }
        playerScript = player.GetComponent <Player>();

        if (!introScreen)
        {
            introScreen = GameObject.Find("IntroScreen");
        }
        if (!tutorialScreen)
        {
            tutorialScreen = GameObject.Find("TutorialScreen");
        }
        if (!gameScreen)
        {
            gameScreen = GameObject.Find("GameScreen");
        }
        if (!levelTransitionScreen)
        {
            levelTransitionScreen = GameObject.Find("LevelTransitionScreen");
        }
        if (!gameOverScreen)
        {
            gameOverScreen = GameObject.Find("GameOverScreen");
        }

        if (!setupPanel)
        {
            setupPanel = GameObject.Find("SetupPanel");
        }

        if (!tm)
        {
            tm = GameObject.Find("TrapManager").GetComponent <TrapManager>();
        }
        if (!kidSpawner)
        {
            kidSpawner = GameObject.Find("KidSpawner").GetComponent <KidSpawner>();
        }
        if (!timeSlider)
        {
            timeSlider = GameObject.Find("TimeSlider").GetComponent <Slider>();
        }
        timeSlider.value = 1;
        modeText         = timeSlider.GetComponentInChildren <Text>();
        if (!levelText)
        {
            levelText = GameObject.Find("LevelText").GetComponent <Text>();
        }
        if (!scoreText)
        {
            scoreText = GameObject.Find("ScoreText").GetComponent <Text>();
        }
        if (!middleText)
        {
            middleText = GameObject.Find("MiddleText").GetComponent <Text>();
        }

        if (!livesDisplay)
        {
            livesDisplay = GameObject.Find("Lives").GetComponent <LivesDisplay>();
        }

        gameScreen.SetActive(true);

        floor2_y = GameObject.Find("Floor2").transform.position.y - 1.5f;
        floor3_y = GameObject.Find("Floor3").transform.position.y - 1.5f;

        string[] trapTriggerNames = new string[] { "11", "12", "13", "21", "22", "23", "31", "32", "33" };
        trapTriggers = new List <TrapTrigger>();
        foreach (string s in trapTriggerNames)
        {
            trapTriggers.Add(GameObject.Find(s).GetComponent <TrapTrigger>());
        }

        introScreen.SetActive(false);
        gameScreen.SetActive(false);
        levelTransitionScreen.SetActive(false);
        gameOverScreen.SetActive(false);

        levelTimer = setupTimerMax;
    }
Esempio n. 33
0
 void Awake()
 {
     trapManagerInstance = this;
 }