Beispiel #1
0
    void Update()
    {
        if (Network.isServer)
        {
            //Every X frames
            if (Time.frameCount % 15 == 0)
            {
                //pick a random wall
                int r = rng.Next() % mazeSize;
                int c = rng.Next() % mazeSize;

                //get the wallscript
                WallScript ws     = WallArray[r][c].GetComponent <WallScript>();
                float      height = ws.GetHeight();

                if (height == 1.0f)
                {
                    ws.SetHeight(0.0f);
                    //Debug.Log("raising wall at row " + r + ", col "+c);
                }
                else if (height == 0.0f)
                {
                    ws.SetHeight(1.0f);
                    //Debug.Log("lowering wall at row " + r + ", col "+c);
                }

                networkView.RPC("moveWall", RPCMode.Others, r, c, (int)ws.GetHeight());
            }
        }
    }
Beispiel #2
0
    void SendDataToPlayers()
    {
        string dataToSend = "";

        foreach (GameObject[] GOarray in WallArray)
        {
            foreach (GameObject GO in GOarray)
            {
                WallScript ws = GO.GetComponent <WallScript>();
                int        r  = ws.getRow();
                int        c  = ws.getCol();
                dataToSend += r + "," + c + "," + ws.GetHeight() + "|";
            }

            dataToSend = dataToSend.Substring(0, dataToSend.Length - 1);
            //Debug.Log("Sending data: "+ dataToSend);
            networkView.RPC("setMaze", RPCMode.Others, dataToSend);
            dataToSend = "";

            //Had to send the data at the end of every Row, turns out
            //that 4080 something characters was the maximum string allowed
            //to be sent through RPC calls.
        }

        networkView.RPC("setMaze", RPCMode.Others, "DONE");
    }
Beispiel #3
0
    void setMaze(string data)
    {
        //Debug.Log ("setmaze called");

        //This will be sent by the server when it has sent all its data.
        if (data.Equals("DONE"))
        {
            requestingData = false;
        }
        else
        {
            //This prevents unnecessary calculations for players who already have map data.
            if (requestingData)
            {
                //Debug.Log("Recieving data: " + data);

                string[] allDataSplit = data.Split('|');
                foreach (string str in allDataSplit)
                {
                    string[] finalSplit = str.Split(',');             //0 = row, 1 = col, 2 = raised/lowered.
                    int      r          = int.Parse(finalSplit[0]);
                    int      c          = int.Parse(finalSplit[1]);
                    int      val        = int.Parse(finalSplit[2]);


                    WallScript ws = WallArray[r][c].GetComponent <WallScript>();
                    ws.SetHeight(val);
                }
            }
        }
    }
Beispiel #4
0
    void OnTriggerEnter2D(Collider2D otherCollider)
    {
        // Collision with enemy
        WallScript wallsc = otherCollider.gameObject.GetComponent <WallScript>();

        if (wallsc != null)
        {
            // Kill the enemy
            if (!wallsc.red)
            {
                Destroy(gameObject);
                ScoreScript.Instance.UpdateScore(2);
                ScoreScript.Instance.UpdateCoins(10);
            }
            else
            {
                speed += new Vector2(5f, 5f);
            }
        }
        else if (otherCollider.tag == "Chest")
        {
            Destroy(gameObject);
            ScoreScript.Instance.UpdateCoins(-50);
        }
    }
Beispiel #5
0
    private void OnMouseDown()
    {
        if (status.Equals("Active"))
        {
            Debug.Log("KlikitiKlik");
            waiting.SetActive(true);

            switch (currentCard.cardName)
            {
            case "Freeze":
            {
                FreezeScript scriptSettings = activated.transform.parent.gameObject.AddComponent <FreezeScript>();
                scriptSettings.time = currentCard.time;
                break;
            }

            case "Wall": {
                WallScript scriptSettings = activated.transform.parent.gameObject.AddComponent <WallScript>();
                scriptSettings.time = currentCard.time;
                break;
            }
            }

            activated.SetActive(false);
            status = "Waiting";
        }
    }
Beispiel #6
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        PlayerWeaponScript projectile = collider.gameObject.GetComponent <PlayerWeaponScript>();
        PlayerController   player     = collider.gameObject.GetComponent <PlayerController>();
        WallScript         wall       = collider.gameObject.GetComponent <WallScript>();

        try
        {
            if (!(projectile == null))
            {
                if (!projectile.shotType.Equals("plasma") && !projectile.shotType.Equals("rock"))
                {
                    Destroy(collider.gameObject);
                }
            }
            if (player != null && (caster != null && !caster.Equals(player)))
            {
                player.health.ManualDamage(1, "rock");
            }
        }
        catch (System.NullReferenceException e) {
            if (!(wall == null))
            {
                gameObject.GetComponent <Rigidbody2D>().isKinematic = false;
            }
        }
    }
Beispiel #7
0
    protected override void OnCantMove <T> (T component)
    {
        WallScript hitWall = component as WallScript;

        hitWall.DamageWall(wallDamage);
        animator.SetTrigger("playerChop");
    }
Beispiel #8
0
    void artifactLockNetworked(int x, int z)
    {
        //Lock the artifact wall.
        WallScript artifactWallScript = WallArray[x][z].GetComponent <WallScript>();

        artifactWallScript.setLockState(true);
        artifactWallScript.setLockedStateFIX();         // dont mind me, just a dumb bug
    }
Beispiel #9
0
    void OnTriggerExit2D(Collider2D collider)
    {
        WallScript wall = collider.gameObject.GetComponent <WallScript>();

        if (wall != null)
        {
            gameObject.GetComponent <Rigidbody2D>().isKinematic = true;
        }
    }
Beispiel #10
0
    private int spawnWalls(int i, int currentTotalWalls)
    {
        // control the speed variable
        if (currentTotalWalls == 1)
        {
            currentWallSpeed = 0.1f;
        }
        else if (currentTotalWalls % 5 == 0)
        {
            currentWallSpeed = currentWallSpeed + 0.07f;
        }

        setRespawnTime(Random.Range(1.5f, 4.0f));

        // Spawn wall and obstacle N times where N times is requried to be set;
        if ((i % 2) == 0)
        {
            // increment walls only when wall is spawned
            currentTotalWalls++;

            randWall = Random.Range(1, 4);

            // adds random walls to the scene and assign speed as each object is instantiated
            if (randWall == 1)
            {
                GameObject a = Instantiate(wallBasic1) as GameObject;
                a.transform.position = new Vector3(-1.193203f, 6.31f, 92f);
                WallScript ws = a.GetComponent <WallScript>();
                ws.setWallSpeed(currentWallSpeed);
            }
            else if (randWall == 2)
            {
                GameObject a = Instantiate(wallBasic2) as GameObject;
                a.transform.position = new Vector3(-5.893f, 6.31f, 92f);
                WallScript ws = a.GetComponent <WallScript>();
                ws.setWallSpeed(currentWallSpeed);
            }
            else if (randWall == 3)
            {
                GameObject a = Instantiate(wallBasic3) as GameObject;
                a.transform.position = new Vector3(3.158229f, 6.31f, 92f);
                WallScript ws = a.GetComponent <WallScript>();
                ws.setWallSpeed(currentWallSpeed);
            }
        }
        else
        {
            // adds ball obstacle to the scene in random x location.
            float      randomX  = Random.Range(-7f, 7f);
            GameObject obstacle = Instantiate(ballObject) as GameObject;
            obstacle.transform.position = new Vector3(randomX, 5f, 90f);
            ObstacleScript os = obstacle.GetComponent <ObstacleScript>();
            os.setObstacleSpeed(currentWallSpeed);
        }

        return(currentTotalWalls);
    }
Beispiel #11
0
    // Sets whether or not we should allow walls to be movable
    public void SetEditor(bool edit)
    {
        WallScript tempScript = null;

        for (int counter = 0; counter < walls.Count; counter++)
        {
            tempScript = walls[counter].GetComponent <WallScript>();
            tempScript.SetEditor(edit);
        }
    }
Beispiel #12
0
    void RaycastTrigger(Collider2D collider)
    {
        WallScript wall = collider.gameObject.GetComponent <WallScript>();

        if (wall != null && !wall.bounceConstraint)
        {
            direction.x *= -1;
            direction.y *= -1;
        }
    }
Beispiel #13
0
    void SpawnNewLevel()
    {
        Instantiate(platformPrefabs[Random.Range(0, platformPrefabs.Length - 1)], new Vector3(0, platformHeight * level + 5, 0), Quaternion.identity);
        GameObject go    = (GameObject)Instantiate(knifes, new Vector3(0, platformHeight * level + 5, 0), Quaternion.identity);
        WallScript wall1 = go.transform.GetChild(0).gameObject.GetComponent <WallScript>();
        WallScript wall2 = go.transform.GetChild(1).gameObject.GetComponent <WallScript>();

        wall1.ChangeValues((gameSpeed * 0.1f), (gameSpeed * 0.5f)); //Sets up the values for the wall script to move in accordance with the game
        wall2.ChangeValues((gameSpeed * 0.1f), (gameSpeed * 0.5f)); //Sets up the values for the wall script to move in accordance with the game
    }
    // Use this for initialization

    private void OnCollisionEnter(Collision collision)
    {
        StartCoroutine(ClearOut());
        WallScript ws = collision.rigidbody.gameObject.GetComponent <WallScript>();

        if (ws != null)
        {
            StartCoroutine(ws.DestroyInSeconds(0f));
        }
    }
Beispiel #15
0
void fadeeverything()
{
	for(int j=1;j<=7;j+=2)
	{
		fadeit=GameObject.Find("FadePlayer"+j.ToString());
			WallScript wallsc2 = fadeit.GetComponent<WallScript>();
		FaderScript fadescript = fadeit.GetComponent<FaderScript>();
			Debug.Log ("ID: "+wallsc2.id.ToString()+" owner: "+wallsc2.owner.ToString());
		fadescript.TotalFade();
	}
}
Beispiel #16
0
 void OnCollisionEnter(Collision col)
 {
     if (col.gameObject.tag == "Zid" && GameScript.gameState != GameScript.GameStates.wallHit)
     {
         SpecialEffectsScript.PlayAttackSound();
         WallScript.disableWall();
         GameScript.gameState = GameScript.GameStates.wallHit;
         GameScript.advanceLevel(0.1f);
         Debug.Log("Lovit");
     }
 }
Beispiel #17
0
 private void OnTriggerStay2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "Wall")
     {
         if (collision.gameObject.GetComponent <WallScript>().AddUnit(gameObject))
         {
             wallScript         = collision.gameObject.GetComponent <WallScript>();
             movement.MoveSpeed = 0;
         }
     }
 }
    /*
     *  Init is called at the image loading
     */
    public void Init(Transform parent, WallScript wallScript, string objectName)
    {
        this.transform.SetParent(parent, false);
        this.wall = wallScript;
        this.draggableObjectName = objectName;

        this.CurrentState = ObjectState.Idle;
        this.isTriggered  = false;
        this.layer        = -1;

        destinationScale = transform.localScale;
    }
Beispiel #19
0
    int[] findOpenSpaceNear(int x, int z)
    {
        while (true)
        {
            //try to find open space.
            WallScript ws = WallArray[x][z].GetComponent <WallScript>();
            if (ws.GetHeight() == 1 && ws.getLockState() == false)
            {
                //this X and Y location is good. Break.
                Debug.Log("Found open space at x:" + x + ", z:" + z);
                break;
            }

            //This space isn't open, get one nearby then loop.
            else
            {
                //Get random new location nearby.
                int dir = rng.Next() % 4;
                switch (dir)
                {
                case 0: x++; break;

                case 1: x--; break;

                case 2: z++; break;

                case 3: z--; break;
                }

                //make sure we don't go OOB.
                if (x > mazeSize)
                {
                    x--;
                }
                else if (x < 0)
                {
                    x++;
                }
                if (z > mazeSize)
                {
                    z--;
                }
                else if (z < 0)
                {
                    z++;
                }
            }
        }
        return(new int[2] {
            x, z
        });
    }
Beispiel #20
0
    void hideObject(GameObject toHide)
    {
        WallScript block = null;

        if (toHide != null)
        {
            block = toHide.GetComponent <WallScript>();
        }
        if (block != null)
        {
            block.Hide();
        }
    }
Beispiel #21
0
    void ShowObject(GameObject toShow)
    {
        WallScript block = null;

        if (toShow != null)
        {
            block = toShow.GetComponent <WallScript>();
        }
        if (block != null)
        {
            block.Show();
        }
    }
Beispiel #22
0
    public static void createWall()
    {
        if (currentLevel < 4)
        {
            WallScript.createMovingWall(16.5f);
        }
        else if (currentLevel < 6)
        {
            WallScript.createMovingWall(8.25f);
        }

        //advanceLevel ();
    }
Beispiel #23
0
    private void DeactivateWalls()
    {
        GameObject room = GameObject.FindGameObjectWithTag("Room");

        for (int i = 0; i < room.transform.childCount; i++)
        {
            Transform  wall       = room.transform.GetChild(i);
            WallScript wallScript = wall.gameObject.GetComponent <WallScript> ();
            if (wallScript.IsSelected())
            {
                wallScript.SetInactive();
            }
        }
    }
Beispiel #24
0
    public bool IsAnithingAtSpwanPlace()
    {
        bool isOnSpawnPlace = false;

        for (int i = 0; i < transform.childCount; i++)
        {
            WallScript wall = transform.GetChild(i).GetComponent <WallScript> ();
            if (wall.transform.position == wall.startingPosition)
            {
                isOnSpawnPlace = true;
            }
        }
        return(isOnSpawnPlace);
    }
    void OnSceneGUI()
    {
        WallScript example = (WallScript)target;

        EditorGUI.BeginChangeCheck();
        for (int i = 0; i < example.meshPoints.Length; i++)
        {
            example.meshPoints[i] = Handles.PositionHandle(example.meshPoints[i], Quaternion.identity);
        }
        if (EditorGUI.EndChangeCheck())
        {
            example.SetMesh();
        }
    }
Beispiel #26
0
    private void Awake()
    {
        WallScript wall = GetComponent <WallScript>();

        LayerMask  layerMask = 1 << LayerMask.NameToLayer("Ground");
        RaycastHit groundBlock;

        if (Physics.Raycast(actualTransform.transform.position, actualTransform.TransformDirection(Vector3.down), out groundBlock, layerMask))
        {
            GroundScript ground = groundBlock.collider.GetComponentInParent <GroundScript>();

            ground.type       = wall.type;
            ground.freeSocket = false;
        }
    }
Beispiel #27
0
 void Start()
 {
     myRenderer.sortingOrder = (int)((transform.position.y - myRenderer.bounds.extents.y) * GlobalRegistry.SORTING_Y_MULTIPLIER());
     //Populate Polygon Mesh
     //Call GlobalRegistry for rank of this wall
     //It's possible rank 1 has already called getEntries on this wall, so make sure walLRank hasn't been set yet
     if (wallRank == 0)
     {
         wallRank = GlobalRegistry.GetWallRank();
     }
     if (wallRank == 1)
     {
         rankOne = this;
     }
 }
Beispiel #28
0
    public void populateFirstRank()
    {
        //If this wall's rank is the first one:
        if (wallRank == 1)
        {
            //Make EdgeCollider for this wall
            List <int> usedRanks = MakeEdgeCollider();
            List <int> wallsInt  = Enumerable.Range(1, GlobalRegistry.GetWallNum()).ToList();


            GameObject[] wallsInScene = GameObject.FindGameObjectsWithTag("Wall");
            WallScript   makingWall   = this;
            //do {
            //Find if there are wall ranks that weren't used
            foreach (GameObject wall in wallsInScene)
            {
                WallScript checkingWall = wall.GetComponent <WallScript>();
                if (usedRanks.Contains(checkingWall.GetRank()))
                {
                    wallsInt.Remove(checkingWall.GetRank());
                    //Tell each wall that they are in this wall
                    if (makingWall.GetEdgeCollider())
                    {
                        checkingWall.SetEdgeCollider(makingWall.GetEdgeCollider());
                    }
                }
            }

            /*
             * if(wallsInt.Count > 0) {
             *      //Get all ranks and call MakeEdgeCollider on the first one remaining in wallsInt
             *      foreach(GameObject wall in wallsInScene) {
             *              makingWall = wall.GetComponent<WallScript>();
             *              if(wallsInt.Contains(makingWall.GetRank())) {
             *                      usedRanks = makingWall.MakeEdgeCollider();
             *                      break;
             *              }
             *      }
             * }
             * numLoops++;
             * } while(wallsInt.Count > 0 && numLoops < GlobalRegistry.GetWallNum());*/

            foreach (int rank in wallsInt)
            {
                Debug.LogException(new Exception("Unused rank " + rank), this);
            }
        }
    }
Beispiel #29
0
    IEnumerator crushSpider(float duration = 0.5f)
    {
        WallScript.destroyWall();
        float bigDelta = 0;

        yield return(new WaitForSeconds(0.4f));

        while (bigDelta < duration)
        {
            bigDelta += Time.deltaTime;
            boot.transform.position    = Vector3.Lerp(bootStartPosition, bootEndPosition, bigDelta / duration);
            boot.transform.eulerAngles = Vector3.Lerp(new Vector3(-bootRotation, 270, 0), new Vector3(0, 270, 0), bigDelta / duration);
            yield return(null);
        }
        gameState = GameStates.dead;
    }
 // Use this for initialization
 void Start()
 {
     TownWall = GameObject.Find ("Helms Deep");
     wallCode = TownWall.GetComponent <WallScript>();
     // Setting the navigation to autopath the enemies to the wall
     OriginHP = HP;
     // Getting position of wall
     wall = GameObject.Find ("enemyDestination");
     wallPlace = wall.GetComponent<Transform>();
     // Getting NavMesh component
     enemy = GetComponent<NavMeshAgent>();
     enemy.enabled = true;
     // Setting destination of enemy
     newDestination = new Vector3(wallPlace.position.x, gameObject.transform.position.y, gameObject.transform.position.z);
     enemy.destination = newDestination;
 }
Beispiel #31
0
    public Vector2 GetFrontWall()
    {
        int        w = 1;
        int        h = 1;
        WallScript r = right;

        while (r != null && r.needFront)
        {
            w++;
            r.needFront = false;
            r           = r.right;
        }
        WallScript d = down;

        while (d != null && d.needFront)
        {
            r = d;
            bool rowSafe = true;
            for (int i = 0; i < w; i++)
            {
                if (r == null || !r.needFront)
                {
                    rowSafe = false;
                    break;
                }
                r = r.right;
            }
            if (rowSafe)
            {
                h++;
                r = d;
                for (int i = 0; i < w; i++)
                {
                    r.needFront = false;
                    r           = r.right;
                }
                d = d.down;
            }
            else
            {
                break;
            }
        }
        return(new Vector2(w, h));
    }
Beispiel #32
0
    /*
	 * 	Start / Update
	 */
    public void Init(Transform parent, WallScript wall, string name){
		this.transform.SetParent(parent, false);
        this.CurrentState = ObjectState.Idle;
        this.draggableObjectName = name;
        this.isTriggered = false;
        //this.scaleImmediatly = false;
        this.wall = wall;
		this.layer = -1;

        var collider = GetComponent<BoxCollider2D>();
        collider.isTrigger = true;
    }
Beispiel #33
0
	void Awake(){
		Wall = GetComponent<WallScript> ();
		MovingLine = new List <Vector2[]> ();
	}
    // To find which wall is the hob attached to.
    void HobWall()
    {
        Vector3 hobWallPoint = Vector3.zero;

        foreach (GameObject cabinet in CabinetManager.Instance.cabinetsInScene) {
            if(cabinet.GetComponent<CabinetScript>()._typeOfCabinet == CabinetScript.TypeOfCabinet.Hob)
            {
                hobOnWall = cabinet.GetComponent<CabinetScript>().attachedToWall.GetComponent<WallScript>();

        //				print ("the hob is atached to "+hobOnWall.name);

                if(hobOnWall.name == "topWall")
                {
                    hobWallPoint = new Vector3(cabinet.transform.position.x,cabinet.transform.position.y,cabinet.transform.position.z + cabinet.GetComponent<CabinetScript>().boundExtends.z);
                    isHobAlongTheWidth = true;
                }

                if(hobOnWall.name == "bottomWall")
                {
                    hobWallPoint = new Vector3(cabinet.transform.position.x,cabinet.transform.position.y,cabinet.transform.position.z - cabinet.GetComponent<CabinetScript>().boundExtends.z);
                    isHobAlongTheWidth = true;
                }

                if(hobOnWall.name == "leftWall")
                {
                    hobWallPoint = new Vector3(cabinet.transform.position.x - cabinet.GetComponent<CabinetScript>().boundExtends.x,cabinet.transform.position.y,cabinet.transform.position.z);
                    isHobAlongTheWidth = false;
                }

                if(hobOnWall.name == "rightWall")
                {
                    hobWallPoint = new Vector3(cabinet.transform.position.x + cabinet.GetComponent<CabinetScript>().boundExtends.x,cabinet.transform.position.y,cabinet.transform.position.z);
                    isHobAlongTheWidth = false;
                }

                distanceFromInitailVertToHob = Vector3.Distance (hobOnWall.initialVertex.transform.position,hobWallPoint);
                distanceFromFinalVertToHob = Vector3.Distance (hobOnWall.finalVertex.transform.position,hobWallPoint);
            }
        }
    }