Esempio n. 1
0
    private void onSpawnSoul(SpawnSoul spawn)
    {
        Debug.LogFormat("spawn a soul: {0} at {1}", spawn.playerName, spawn.position);
        GameObject soul = Instantiate(soulPrefab, spawn.position, Quaternion.identity);

        if (spawn.playerName != "")
        {
            soul.name = spawn.playerName;
        }
        else
        {
            soul.name = "F**K";
        }

        GameObject allSouls = GameObject.Find("Souls");

        if (allSouls == null)
        {
            Debug.LogError("unable to find souls container!");
        }
        else
        {
            soul.transform.SetParent(allSouls.transform);

            SoulController sc = soul.GetComponent <SoulController>();
            sc.playerName = spawn.playerName;
        }
    }
Esempio n. 2
0
    private void parseMessage(string msg)
    {
        string[] parts = msg.Split(new char[] { ' ' }, 2);
        if (parts.Length != 2)
        {
            Debug.LogFormat("dunno how to handle this msg: {0}", msg);
            return;
        }
        switch (parts[0])
        {
        case "spawn-soul":
            SpawnSoul spawned = JsonUtility.FromJson <SpawnSoul>(parts[1]);
            onSpawnSoul(spawned);
            break;

        case "soul-collected":
            CollectSoul collected = JsonUtility.FromJson <CollectSoul>(parts[1]);
            onSoulCollected(collected);
            break;

        case "login-result":
            Debug.LogFormat("received message: {0}", msg);
            LoginResult login = JsonUtility.FromJson <LoginResult>(parts[1]);
            onLoginResult(login);
            break;

        case "tick":
            break;

        default:
            Debug.LogFormat("also can't handle this one: {0} {1}", parts[0], parts[1]);
            break;
        }
    }
Esempio n. 3
0
 // Use this for initialization
 void Start()
 {
     maxHealth     = 3;
     currentHealth = maxHealth;
     soulSpawn     = gameObject.GetComponent <SpawnSoul>();
     if (gameObject.tag == "Player")
     {
         isEnemy = false;
     }
     else
     {
         ourPooledObject = GetComponent <PooledObject>();
         enemy           = GetComponent <Enemy>();
         isEnemy         = true;
     }
 }