Exemple #1
0
    // 初始P-BaseDefense游戏相关设定
    public void Initinal()
    {
        // 场景状态控制
        m_bGameOver = false;
        // 游戏系统
        m_GameEventSystem   = new GameEventSystem(this);   // 游戏事件系统
        m_CampSystem        = new CampSystem(this);        // 兵营系统
        m_StageSystem       = new StageSystem(this);       // 关卡系统
        m_CharacterSystem   = new CharacterSystem(this);   // 角色管理系统
        m_ApSystem          = new APSystem(this);          // 行动力系统
        m_AchievementSystem = new AchievementSystem(this); // 成就系统
                                                           // 界面
        m_CampInfoUI      = new CampInfoUI(this);          // 兵营信息
        m_SoldierInfoUI   = new SoldierInfoUI(this);       // Soldier信息
        m_GameStateInfoUI = new GameStateInfoUI(this);     // 游戏资料
        m_GamePauseUI     = new GamePauseUI(this);         // 游戏暂停

        // 注入到其它系统
        EnemyAI.SetStageSystem(m_StageSystem);

        // 载入存档
        LoadData();

        // 注册游戏事件系统
        ResigerGameEvent();
    }
    // 初始P-BaseDefense遊戲相關設定
    public void Initinal()
    {
        // 場景狀態控制
        m_bGameOver = false;
        // 遊戲系統
        m_GameEventSystem   = new GameEventSystem(this);        // 遊戲事件系統
        m_CampSystem        = new CampSystem(this);             // 兵營系統
        m_StageSystem       = new StageSystem(this);            // 關卡系統
        m_CharacterSystem   = new CharacterSystem(this);        // 角色管理系統
        m_ApSystem          = new APSystem(this);               // 行動力系統
        m_AchievementSystem = new AchievementSystem(this);      // 成就系統
        // 界面
        m_CampInfoUI      = new CampInfoUI(this);               // 兵營資訊
        m_SoldierInfoUI   = new SoldierInfoUI(this);            // Soldier資訊
        m_GameStateInfoUI = new GameStateInfoUI(this);          // 遊戲資料
        m_GamePauseUI     = new GamePauseUI(this);              // 遊戲暫停

        // 注入到其它系統
        EnemyAI.SetStageSystem(m_StageSystem);

        // 載入存檔
        LoadData();

        // 註冊遊戲事件系統
        ResigerGameEvent();
    }
 void SendOrder(Order order, CharacterSystem targetUnit)
 {
     if (targetUnit != null)
     {
         targetUnit.RecieveOrder(order, _originUnit);
     }
 }
    private CameraController cam_controller; // referencia para o controlador da camera

    // referencias para a camera

    // on awake
    private void Awake()
    {
        // define a forma do jogador como Aike
        char_info.shape = PlayerShape.Aike;

        // inicia o jogador e a camera no mundo de acordo com o spawn point
        // guarda referencia para o controlador do jogador
        char_system_ = GameObject.Instantiate(PlayerObject, Spawner_point.position, Spawner_point.rotation).
                       GetComponent <CharacterSystem>();
        // guarda referencia para o transform do jogador
        char_transform_ = char_system_.transform;

        // indica que o jogador pode trocar de forma
        char_system_.CanGoArif(true);
        // torna o jogador vivo
        char_system_.RespawnPlayer();
        // confirma a escala do tempo para o jogador
        char_system_.game_settings_.SetTimeMultiplier(1f);

        // inicia a camera
        cam_controller = GameObject.Instantiate(CameraControllerObject,
                                                Spawner_point.position, Spawner_point.rotation).GetComponent <CameraController>();

        // defini volume dos listenners
        char_system_.game_settings_.SetListenerVolume();

        // determinar qual portal está aberto
        ConfirmPortals();
    }
 public void Set(OrderImpulse order, CharacterSystem originUnit, Vector3 targetPosition)
 {
     _order              = order;
     _originUnit         = originUnit;
     _targetPosition     = targetPosition;
     _integrateUnitFound = false;
 }
    public void EquipItemAI()
    {
        if (isServer)
        {
            if (!alreadyEquip)
            {
                for (int i = 0; i < AIs.Length; i++)
                {
                    if (AIs[i] != null)
                    {
                        CharacterSystem character = AIs[i].GetComponent <CharacterSystem>();
                        if (character != null)
                        {
                            character.inventory.ApplyStarterItem();
                        }

                        AICharacterShooterNav ai = AIs[i].GetComponent <AICharacterShooterNav>();
                        if (ai != null)
                        {
                            ai.Fighting = true;
                        }
                    }
                }
                alreadyEquip = true;
            }
        }
    }
    private void damageUpdate()
    {
        // damage a players if they out of the blue area every second
        if (Time.time >= dmTimeTmp + 1)
        {
            for (int i = 0; i < allPlayer.Length; i++)
            {
                if (allPlayer[i] != null)
                {
                    CharacterSystem player = allPlayer[i].GetComponent <CharacterSystem>();
                    if (player != null)
                    {
                        if (lastDeadArea != null && lastDeadArea.activeSelf)
                        {
                            Vector3 playerPos = player.transform.position;
                            playerPos.y = 0;
                            Vector3 deadAreaPos = lastDeadArea.transform.position;
                            deadAreaPos.y = 0;

                            float distance = Vector3.Distance(player.transform.position, lastDeadArea.transform.position);
                            if (distance > (lastDeadArea.transform.localScale.x / 2.0f))
                            {
                                // apply damage 1 to player
                                player.ApplyDamage(currentAreaDamage, Vector3.up, -1, 0);
                            }
                        }
                    }
                }
            }
            dmTimeTmp = Time.time;
        }
    }
    void Update()
    {
        var distance = Vector3.Distance(transform.position, Camera.main.transform.position);

        if (distance < 12.5f)
        {
            m_audiosource.volume = 1;
        }
        else
        {
            m_audiosource.volume = 0;
        }
        if (activeDelayCount <= Time.time)
        {
            activeDelayCount = Time.time + activeDelay;
            m_animator.SetTrigger("Active");
            m_audiosource.PlayOneShot(activeSound);
        }
        if (isActive)
        {
            var startPoint = new Vector2(transform.position.x + m_coliderChecker.offset.x, transform.position.y + m_coliderChecker.offset.y);
            var hit        = Physics2D.OverlapBox(startPoint, m_coliderChecker.size, 0f, LayerMask.GetMask("Player", "Enemy"));
            if (hit)
            {
                CharacterSystem temp = hit.GetComponent <CharacterSystem>();
                if (temp)
                {
                    temp.SetDead(transform.position);
                    isActive = false;
                    m_animator.SetBool("isKill", true);
                    m_audiosource.PlayOneShot(killSound);
                }
            }
        }
    }
 protected virtual void Start()
 {
     weaponSystem    = GetComponent <WeaponSystem>();
     characterSystem = GetComponent <CharacterSystem>();
     abilitySystem   = GetComponent <AbilitySystem>();
     healthSystem    = GetComponent <HealthSystem>();
 }
Exemple #10
0
    void Start()
    {
        animator    = this.GetComponent <Animator>();
        audioSource = this.GetComponent <AudioSource>();
        if (this.transform.root)
        {
            character     = this.transform.root.GetComponent <CharacterSystem>();
            fpsController = this.transform.root.GetComponent <FPSController>();
            if (character == null)
            {
                character = this.transform.root.GetComponentInChildren <CharacterSystem>();
            }
            if (fpsController == null)
            {
                fpsController = this.transform.root.GetComponentInChildren <FPSController>();
            }
        }
        else
        {
            character     = this.transform.GetComponent <CharacterSystem>();
            fpsController = this.transform.GetComponent <FPSController>();
        }

        timeTemp = Time.time;
        if (ItemIndicator)
        {
            preplacingObject = (GameObject)GameObject.Instantiate(ItemIndicator.gameObject, this.transform.position, ItemIndicator.transform.rotation);
        }
    }
    string currentPatch           = string.Empty;                      //current patch;
    // Use this for initialization

    IEnumerator Start()
    {
        ICharacterSystem sys = new CharacterSystem();

        yield return(StartCoroutine(sys.Initialize()));

        clothData = ClothModel.GetData();
        IniClothType();
        playerParent = GameObject.Find("Stage/playerRoot");

        EventTriggerListener.Get(male).onClicks.Add(male_Click);
        EventTriggerListener.Get(female).onClicks.Add(female_Click);

        EventTriggerListener.Get(lod1).onClicks.Add(delegate() { TaskServices.CreateTask(lod_Click(1)).Start(); });
        EventTriggerListener.Get(lod2).onClicks.Add(delegate() { TaskServices.CreateTask(lod_Click(2)).Start(); });
        EventTriggerListener.Get(lod3).onClicks.Add(delegate() { TaskServices.CreateTask(lod_Click(3)).Start(); });
        EventTriggerListener.Get(lod4).onClicks.Add(delegate() { TaskServices.CreateTask(lod_Click(4)).Start(); });
        EventTriggerListener.Get(lod5).onClicks.Add(delegate() { TaskServices.CreateTask(lod_Click(5)).Start(); });
        EventTriggerListener.Get(lod6).onClicks.Add(delegate() { TaskServices.CreateTask(lod_Click(0)).Start(); });
        EventTriggerListener.Get(tempBtn).onClicks.Add(tempBtn_Click);

        female_Click();
        //male_Click();

        UseTimeAlphaManager.StartTimeAlpha(UseTimeAlphaManager.LoadRole);
    }
Exemple #12
0
    public void Init()
    {
        mArchievementSystem = new ArchievementSystem();
        mCampSystem         = new CampSystem();
        mCharacterSystem    = new CharacterSystem();
        mEnergySystem       = new EnergySystem();
        mGameEventSystem    = new GameEventSystem();
        mStageSystem        = new StageSystem();

        mCampInfoUI      = new CampInfoUI();
        mGamePauseUI     = new GamePauseUI();
        mGameStateInfoUI = new GameStateInfoUI();
        mSoldierInfoUI   = new SoldierInfoUI();

        mArchievementSystem.Init();
        mCampSystem.Init();
        mCharacterSystem.Init();
        mEnergySystem.Init();
        mGameEventSystem.Init();
        mStageSystem.Init();

        mCampInfoUI.Init();
        mGamePauseUI.Init();
        mGameStateInfoUI.Init();
        mSoldierInfoUI.Init();

        LoadMemento();
    }
 void Start()
 {
     character = this.GetComponent <CharacterSystem>();
     ai        = character.GetComponent <AICharacterShooterNav>();
     timeTmp   = Time.time;
     TimeWait  = Random.Range(TimeWait / 2, TimeWait);
 }
Exemple #14
0
    //存储玩家
    public void SavePlayer(CharacterSystem character)
    {
        if (UnitZ.gameManager == null || character == null)
        {
            return;
        }

        PlayersRegister(UnitZ.gameManager.UserID);
        PlayerSaveData playersave = new PlayerSaveData();

        playersave.UID          = UnitZ.gameManager.UserID;
        playersave.PlayerName   = UnitZ.gameManager.UserName;
        playersave.CharacterKey = character.CharacterKey;
        playersave.ItemData     = character.inventory.GetItemDataText();
        playersave.EquipData    = character.inventory.GenStickerTextData();
        playersave.FPSItemIndex = character.inventory.GetCollectorFPSindex();
        playersave.Position     = character.transform.position.x + "," + character.transform.position.y + "," + character.transform.position.z;
        playersave.LevelName    = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;
        playersave.Health       = character.HP;

        CharacterLiving living = character.GetComponent <CharacterLiving> ();

        if (living)
        {
            playersave.Food  = living.Hungry;
            playersave.Water = living.Water;
        }
        WriteData(playersave);
    }
	// 初始P-BaseDefense遊戲相關設定
	public void Initinal()
	{
		// 場景狀態控制
		m_bGameOver = false;
		// 遊戲系統
		m_GameEventSystem = new GameEventSystem(this);	// 遊戲事件系統
		m_CampSystem = new CampSystem(this);			// 兵營系統
		m_StageSystem = new StageSystem(this);			// 關卡系統
		m_CharacterSystem = new CharacterSystem(this); 	// 角色管理系統
		m_ApSystem = new APSystem(this);				// 行動力系統
		m_AchievementSystem = new AchievementSystem(this); // 成就系統
		// 界面
		m_CampInfoUI = new CampInfoUI(this); 			// 兵營資訊
		m_SoldierInfoUI = new SoldierInfoUI(this); 		// Soldier資訊									
		m_GameStateInfoUI = new GameStateInfoUI(this); 	// 遊戲資料
		m_GamePauseUI = new GamePauseUI (this);			// 遊戲暫停

		// 注入到其它系統
		EnemyAI.SetStageSystem( m_StageSystem );

		// 載入存檔
		LoadData();

		// 註冊遊戲事件系統
		ResigerGameEvent();
	}
Exemple #16
0
    public void Init()
    {
        systems = new List <IGameSystem>();

        achievementSystem = new AchievementSystem();
        campSystem        = new CampSystem();
        CharacterSystem   = new CharacterSystem();
        EnergySystem      = new EnergySystem();
        EventSystem       = new GameEventSystem();
        StageSystem       = new StageSystem();

        CampInfoUI      = new CampInfoUI();
        gamePauseUI     = new GamePauseUI();
        GameStateInfoUI = new GameStateInfoUI();
        soldierInfoUI   = new SoldierInfoUI();

        systems.Add(achievementSystem);
        systems.Add(campSystem);
        systems.Add(CharacterSystem);
        systems.Add(EnergySystem);
        systems.Add(EventSystem);
        systems.Add(StageSystem);

        systems.Add(CampInfoUI);
        systems.Add(gamePauseUI);
        systems.Add(GameStateInfoUI);
        systems.Add(soldierInfoUI);

        systems.ForEach(s => s.Init());


        var memento = CareTaker.RetrieveMemento(); //取回备忘录

        achievementSystem.RestoreMemento(memento); //根据备忘录,恢复成就系统
    }
Exemple #17
0
 void Awake()
 {
     character = this.GetComponent<CharacterSystem>();
     GameObject fpscam = this.transform.FindChild ("FPScamera").gameObject;
     if (fpscam)
         FPScamera = fpscam.GetComponent<FPSCamera> ();
 }
 void Awake()
 {
     m_Instance = this;
     Application.targetFrameRate = 60;
     gameObject.SetActive(false);
     SceneManager.LoadSceneAsync(2, LoadSceneMode.Additive);
 }
 void Start()
 {
     animator    = this.GetComponent <Animator>();
     audioSource = this.GetComponent <AudioSource>();
     if (this.transform.root)
     {
         character     = this.transform.root.GetComponent <CharacterSystem>();
         fpsController = this.transform.root.GetComponent <FPSController>();
         if (character == null)
         {
             character = this.transform.root.GetComponentInChildren <CharacterSystem>();
         }
         if (fpsController == null)
         {
             fpsController = this.transform.root.GetComponentInChildren <FPSController>();
         }
     }
     else
     {
         character     = this.transform.GetComponent <CharacterSystem>();
         fpsController = this.transform.GetComponent <FPSController>();
     }
     timeTemp = Time.time;
     if (AutoUse)
     {
         Use();
         Debug.Log("Using");
     }
 }
Exemple #20
0
    // metodos privados
    // inicializar o jogador
    private void InicializePlayer()
    {
        // define a forma do jogador para Aike
        char_info_.shape = PlayerShape.Aike;

        // instancia o jogador e a camera no mundo de acordo com o primeiro spawnPoint
        // guarda a refenrecia para o controlador ao instanciar
        char_system_ = GameObject.Instantiate(PlayerObject, StartSpawn.position, StartSpawn.rotation).
                       GetComponent <CharacterSystem>();
        // guarda tambem a referencia para o transform do jogador
        char_transform_ = char_system_.transform;

        // define valores iniciais para o estado do jogador para evitar que seja transportado de outras cenas
        char_system_.CanGoArif(true);
        // torna o jogador activo tambem
        char_system_.RespawnPlayer();
        // confirma o valor da escala de tempo
        char_system_.game_settings_.SetTimeMultiplier(1f);

        // inicia a camera, guardando referencia para o controlador da camera
        cam_controller_ = GameObject.Instantiate(CameraControllerObject, StartSpawn.position, StartSpawn.rotation).
                          GetComponent <CameraController>();

        // define o volume do listenner
        char_system_.game_settings_.SetListenerVolume();

        // apos o jogador estar iniciado, indica ao Fenrir a existencia deste
        fenrir_behaviour.ActivateFenrir(char_transform_);
    }
Exemple #21
0
    //最好先Awake, 再Init. Awake中初始化数据, Init中再new对象之类的
    //不然部分new对象比较分散的,就不好给System初始化进行排序,有耦合。比如EventSubject
    public void Init()
    {
        m_AchievementSystem = new AchievementSystem();
        m_CampSystem        = new CampSystem();
        m_CharactorSystem   = new CharacterSystem();
        m_EnergySystem      = new EnergySystem();
        m_GameEventSystem   = new GameEventSystem();
        m_StageSystem       = new StageSystem();
        m_FileDataSystem    = new FileDataSystem();


        m_CampInfoUI      = new CampInfoUI();
        m_GamePauseUI     = new GamePauseUI();
        m_GameStateInfoUI = new GameStateInfoUI();
        m_SolderInfoUI    = new SoldierInfoUI();

        m_FileDataSystem.Init();
        m_AchievementSystem.Init();
        m_CampSystem.Init();
        m_CharactorSystem.Init();
        m_EnergySystem.Init();
        m_GameEventSystem.Init();
        m_StageSystem.Init();

        m_CampInfoUI.Init();
        m_GamePauseUI.Init();
        m_GameStateInfoUI.Init();
        m_SolderInfoUI.Init();
        LoadMemento();
    }
Exemple #22
0
    private SoldierInfoUI m_SoldierInfoUI;           //战士信息

    public void Init()
    {
        m_ArchievementSystem = new ArchievementSystem();
        m_CampSystem         = new CampSystem();
        m_CharacterSystem    = new CharacterSystem();
        m_EnergySystem       = new EnergySystem();
        m_GameEventSystem    = new GameEventSystem();
        m_StageSystem        = new StageSystem();

        m_CampInfoUI      = new CampInfoUI();
        m_GamePauseUI     = new GamePauseUI();
        m_GameStateInfoUI = new GameStateInfoUI();
        m_SoldierInfoUI   = new SoldierInfoUI();

        m_ArchievementSystem.Init();
        m_CampSystem.Init();
        m_CharacterSystem.Init();
        m_EnergySystem.Init();
        m_GameEventSystem.Init();
        m_StageSystem.Init();
        m_CampInfoUI.Init();
        m_GamePauseUI.Init();
        m_GameStateInfoUI.Init();
        m_SoldierInfoUI.Init();
    }
    void Start()
    {
        character = this.GetComponent <CharacterSystem> ();

        InvokeRepeating("stomachUpdate", 1.0f, 1.0f);
        InvokeRepeating("hungryUpdate", 1.0f, 15.0f);
        InvokeRepeating("thirstilyUpdate", 1.0f, 10.0f);
    }
Exemple #24
0
 public override void Pickup(CharacterSystem character)
 {
     if (Door)
     {
         Door.Access(character);
     }
     base.Pickup(character);
 }
Exemple #25
0
    void Start()
    {
        character       = this.gameObject.GetComponent <CharacterStatus>();
        characterAttack = this.gameObject.GetComponent <CharacterAttack>();
        characterSystem = this.gameObject.GetComponent <CharacterSystem>();

        itemManager  = (ItemManager)FindObjectOfType(typeof(ItemManager));
        ItemsEquiped = new ItemSlot[ItemEmbedSlot.Length];
    }
Exemple #26
0
 void Start()
 {
     character = gameObject.GetComponent<CharacterSystem> ();
     living = gameObject.GetComponent<CharacterLiving> ();
     StyleManager style = (StyleManager)GameObject.FindObjectOfType(typeof(StyleManager));
     if(style && !Skin){
         Skin = style.GetSkin(0);
     }
 }
Exemple #27
0
    void Awake()
    {
        return;

        this._mapSystem       = new MapSystem();
        this._characterSystem = new CharacterSystem();
        this._itemSystem      = new ItemSystem();
        this._poolManager     = PoolManager.Instance;
    }
Exemple #28
0
    IEnumerator CreateMouseOrder()
    {
        // Get order type
        RaycastHit2D hit = Physics2D.Raycast(new Vector2(_debug_mainCamera.ScreenToWorldPoint(Input.mousePosition).x, _debug_mainCamera.ScreenToWorldPoint(Input.mousePosition).y), Vector2.zero, 0f);

        if (hit.collider != null && hit.collider.tag == "unit")
        {
            // Impulse or link
            // Debug.Log("Impulse/Link order started");

            CharacterSystem startUnit = hit.collider.gameObject.GetComponent <CharacterSystem>();
            for (;;)
            {
                if (Input.GetMouseButtonUp(0))
                {
                    hit = Physics2D.Raycast(new Vector2(_debug_mainCamera.ScreenToWorldPoint(Input.mousePosition).x, _debug_mainCamera.ScreenToWorldPoint(Input.mousePosition).y), Vector2.zero, 0f);
                    if (hit.collider != null && hit.collider.tag == "unit")
                    {
                        // Link
                    }
                    else
                    {
                        // Impulse
                        Vector3 dragEnd   = _debug_mainCamera.ScreenToWorldPoint(Input.mousePosition);
                        Vector3 dragDelta = Vector2.zero;
                        Vector2 impulse   = new Vector2((startUnit.transform.position - dragEnd).x, (startUnit.transform.position - dragEnd).y);
                        startUnit.RecieveDirectOrder(new OrderImpulse(impulse * _debug_speed));
                        // Debug.Log("Impulse sent"+ impulse);
                    }
                    yield break;
                }
                yield return(null);
            }
        }
        else
        {
            // Camera drag
            Vector3 dragStart   = _debug_mainCamera.ScreenToWorldPoint(Input.mousePosition);
            Vector3 cameraStart = _debug_mainCamera.transform.position;
            // Debug.Log("Camera drag order started");
            for (;;)
            {
                Vector3 dragEnd   = _debug_mainCamera.ScreenToWorldPoint(Input.mousePosition);
                Vector3 dragDelta = dragStart - dragEnd;
                dragDelta.z = 0;
                _debug_mainCamera.transform.position = cameraStart + dragDelta * _debug_cameraDragSpeed;

                if (Input.GetMouseButtonUp(0))
                {
                    yield break;
                }
                yield return(null);
            }
            yield return(null);
        }
    }
Exemple #29
0
 public void Initinal()
 {
     isGameOver        = false;
     apSystem          = new APSystem(this);
     campSystem        = new CampSystem(this);
     stageSystem       = new StageSystem(this);
     gameEventSystem   = new GameEventSystem(this);
     characterSystem   = new CharacterSystem(this);
     achievementSystem = new AchievementSystem(this);
 }
Exemple #30
0
    //接受数据并应用
    public void ReceiveDataAndApply(string datatext, CharacterSystem character)
    {
        //Debug.Log ("Received From Server " + datatext);

        PlayerSaveData playersave = new PlayerSaveData();

        playersave = GetSaveDataFromText(datatext);

        ApplyPlayerData(playersave, character);
    }
Exemple #31
0
 public void OnUpdate()
 {
     ArchievementSystem.OnUpdate();
     CampSystem.OnUpdate();
     CharacterSystem.OnUpdate();
     EnergySystem.OnUpdate();
     GameEventSystem.OnUpdate();
     StageSystem.OnUpdate();
     UISystem.OnUpdate();
 }
 void Start()
 {
     animator  = this.GetComponent <Animator>();
     character = this.GetComponent <CharacterSystem>();
     if (headCamera == null)
     {
         FPSCamera fpscam = this.GetComponentInChildren <FPSCamera>();
         headCamera = fpscam.gameObject.transform;
     }
 }
Exemple #33
0
 public void PickUpStock(CharacterSystem character)
 {
     if (character && character.IsMine)
     {
         character.inventory.PeerTrade = inventory;
         OpenStock();
         UnitZ.Hud.OpenSecondInventory(inventory, "Stock");
     }
     characterTemp = character;
 }
 void Start()
 {
     audioSource = this.GetComponent<AudioSource>();
     if (this.transform.root) {
         character = this.transform.root.GetComponent<CharacterSystem> ();
     } else {
         character = this.transform.GetComponent<CharacterSystem> ();
     }
     if(character)
         character.DamageSound = DamageSound;
 }
    public void Set(OrderImpulse order, CharacterSystem originUnit, CharacterSystem targetUnit)
    {
        _order = order;
        _originUnit = originUnit;
        _targetUnit = targetUnit;
        _integrateUnitFound = false;

        if (originUnit == _targetUnit) {
            StartCoroutine(InitiateDestruction());
            return;
        }
    }
 void Start()
 {
     //AImange = (AIManager)GameObject.FindObjectOfType (typeof(AIManager));
     character = gameObject.GetComponent<CharacterSystem> ();
     positionTemp = this.transform.position;
     aiState = 0;
     attackTemp = Time.time;
     lifeTimeTemp = Time.time;
     jumpTemp = Time.time;
     soundTime = Time.time;
     soundTimeDuration = Random.Range (0, IdleSoundDelay);
     character.ID = "";
 }
Exemple #37
0
 public virtual void Pickup(CharacterSystem character)
 {
     if (character && (character.IsMine || (!Network.isClient && !Network.isServer))) {
         CharacterDriver driver = character.GetComponent<CharacterDriver> ();
         if (driver) {
             for (int i=0; i<Seats.Length; i++) {
                 if (Seats [i].passenger == null) {
                     Debug.Log ("Pick up " + character.name);
                     Seats [i].GetIn (driver);
                     break;
                 }
             }
         }
     }
 }
Exemple #38
0
 void Start()
 {
     animator = this.GetComponent<Animator> ();
     audioSource = this.GetComponent<AudioSource> ();
     if (this.transform.root) {
         character = this.transform.root.GetComponent<CharacterSystem> ();
         fpsController = this.transform.root.GetComponent<FPSController> ();
         if (character == null)
             character = this.transform.root.GetComponentInChildren<CharacterSystem> ();
         if (fpsController == null)
             fpsController = this.transform.root.GetComponentInChildren<FPSController> ();
     } else {
         character = this.transform.GetComponent<CharacterSystem> ();
         fpsController = this.transform.GetComponent<FPSController> ();
     }
     timeTemp = Time.time;
 }
    // When integrating a chain
    public static void IntegratePathBehindUnit(CharacterSystem frontUnit, CharacterSystem newBackUnit)
    {
        // from
        // frontUnit._backUnit => frontUnit
        // to
        // frontUnit._backUnit => newBackUnit => frontUnit

        if (frontUnit._backUnit == null) {
            // If the front unit has no back unit, add the new back unit as the front unit's back unit
            frontUnit._backUnit = newBackUnit;

            /*
            newBackUnit._frontUnits = new List<CharacterSystem>();
            newBackUnit._frontUnits.Add(frontUnit);
            */

        } else {

            if (newBackUnit._backUnit != frontUnit._backUnit) {
                newBackUnit._backUnit = frontUnit._backUnit;
                frontUnit._backUnit = newBackUnit;
            } else {
                newBackUnit._backUnit = null;
                frontUnit._backUnit = newBackUnit;
                return;
            }

            if (newBackUnit._backUnit._frontUnits.Contains(frontUnit)) {
                newBackUnit._backUnit._frontUnits.Remove(frontUnit);
            }

            newBackUnit._backUnit._frontUnits.Add(newBackUnit);

            // Reset front units
            newBackUnit._frontUnits = new List<CharacterSystem>();

            // Add the most recent order giver as unique front unit
            newBackUnit._frontUnits.Add(frontUnit);

            // Set order giver to the new unit
            foreach (OrderSystem orderSystem in newBackUnit._backUnit._pendingOrder) {
                orderSystem._originUnit = newBackUnit;
            }
        }
    }
    void Update()
    {
        if (PlayerManage == null || Canvas == null)
            return;

        mainCharacter = PlayerManage.playingCharacter;

        if (PlayerManage.playingCharacter != null) {
            Canvas.gameObject.SetActive (true);
        } else {
            Canvas.gameObject.SetActive (false);
        }

        if (mainCharacter) {

            InputController ();

            if (HPbar) {
                HPbar.Value = mainCharacter.HP;
                HPbar.ValueMax = mainCharacter.HPmax;
            }
            if (FoodBar && living) {
                FoodBar.Value = living.Hungry;
                FoodBar.ValueMax = living.HungryMax;
            }
            if (WaterBar && living) {
                WaterBar.Value = living.Water;
                WaterBar.ValueMax = living.WaterMax;
            }

            if (living == null)
                living = mainCharacter.GetComponent<CharacterLiving> ();

        } else {
            living = null;
        }
    }
 private void findPlayerCharacter()
 {
     CharacterSystem[] characters = (CharacterSystem[])GameObject.FindObjectsOfType (typeof(CharacterSystem));
     for (int i=0; i<characters.Length; i++) {
         if (characters [i].IsMine) {
             playingCharacter = characters [i];
             return;
         }
     }
 }
Exemple #42
0
    void ApplyPlayerData(PlayerSaveData playersave, CharacterSystem character)
    {
        if (character && character.inventory) {
            //Debug.Log ("Applying ");
            //Debug.Log ("with " + PlayerSaveDataText (playersave));

            character.inventory.SetItemsFromText (playersave.ItemData);
            character.inventory.UpdateOtherInventory (playersave.EquipData);
            if (character.inventory.Items.Count > playersave.FPSItemIndex)
                character.inventory.EquipItemByCollector (character.inventory.Items [playersave.FPSItemIndex]);
            string[] positionraw = playersave.Position.Split ("," [0]);
            if (positionraw.Length > 2) {
                Vector3 position = Vector3.zero;
                float.TryParse (positionraw [0], out position.x);
                float.TryParse (positionraw [1], out position.y);
                float.TryParse (positionraw [2], out position.z);
                character.transform.position = position;
            }

            character.HP = playersave.Health;
            CharacterLiving living = character.GetComponent<CharacterLiving> ();
            if (living) {
                living.Hungry = playersave.Food;
                living.Water = playersave.Water;
            }
            // if new save, all parameter must be set by default.
            if (playersave.Food <= 0 && playersave.Water <= 0 && playersave.Health <= 0) {
                character.HP = character.HPmax;
                if (living) {
                    living.Hungry = living.HungryMax;
                    living.Water = living.WaterMax;
                }
            }

            character.InitializeData ();
        }
    }
    void Start()
    {
        reloading = false;
        animator = this.GetComponent<Animator> ();
        audioSource = this.GetComponent<AudioSource> ();

        if (this.transform.root) {
            character = this.transform.root.GetComponent<CharacterSystem> ();
            fpsController = this.transform.root.GetComponent<FPSController> ();
            if (character == null)
                character = this.transform.root.GetComponentInChildren<CharacterSystem> ();
            if (fpsController == null)
                fpsController = this.transform.root.GetComponentInChildren<FPSController> ();
        } else {
            character = this.transform.GetComponent<CharacterSystem> ();
            fpsController = this.transform.GetComponent<FPSController> ();
        }

        if (character)
            character.DamageSound = DamageSound;

        if (fpsController)
            fpsController.zooming = false;

        Hide (true);
        timeTemp = Time.time;

        StyleManager style = (StyleManager)GameObject.FindObjectOfType (typeof(StyleManager));
        if (style && !Skin) {
            Skin = style.GetSkin (0);
        }
        if (animator) {
            animationSpeedTemp = animator.speed;
        }
    }
Exemple #44
0
    public void ReceiveDataAndApply(string datatext, CharacterSystem character)
    {
        //Debug.Log ("Received From Server " + datatext);

        PlayerSaveData playersave = new PlayerSaveData ();
        playersave = GetSaveDataFromText (datatext);

        ApplyPlayerData (playersave, character);
    }
Exemple #45
0
    public void SavePlayer(CharacterSystem character)
    {
        if (UnitZ.gameManager == null || character == null)
            return;

        PlayersRegister (UnitZ.gameManager.UserID);
        string hasKey = UnitZ.gameManager.UserID;
        PlayerSaveData playersave = new PlayerSaveData ();

        playersave.UID = hasKey;
        playersave.PlayerName = UnitZ.gameManager.UserName;
        playersave.ItemData = character.inventory.GetItemDataText ();
        playersave.EquipData = character.inventory.GenStickerTextData ();
        playersave.FPSItemIndex = character.inventory.GetCollectorFPSindex ();
        playersave.Position = character.transform.position.x + "," + character.transform.position.y + "," + character.transform.position.z;
        playersave.LevelName = Application.loadedLevelName;
        playersave.Health = character.HP;

        CharacterLiving living = character.GetComponent<CharacterLiving> ();
        if (living) {
            playersave.Food = living.Hungry;
            playersave.Water = living.Water;
        }

        if ((!Network.isServer && !Network.isClient) || Network.isServer) {
            WriteData (playersave);
        } else {
            if (networkViewer)
                networkViewer.RPC ("SaveToServer", RPCMode.Server, PlayerSaveDataText (playersave));
        }
    }
    void Start()
    {
        networkViewer = this.GetComponent<NetworkView> ();
        character = this.GetComponent<CharacterSystem> ();

        InvokeRepeating ("stomachUpdate", 1.0f, 1.0f);
        InvokeRepeating ("hungryUpdate", 1.0f, 15.0f);
        InvokeRepeating ("thirstilyUpdate", 1.0f, 10.0f);
    }
    void Start()
    {
        character = gameObject.GetComponent<CharacterSystem> ();
        PlayerView pv = gameObject.GetComponent<PlayerView>();
        if(pv && FPSCamera == null){
            FPSCamera = pv.FPScamera.MainCamera;
            FPSViewPart = pv.FPScamera.transform;
        }

        motor = GetComponent<CharacterMotor> ();
        if (GetComponent<Rigidbody>())
            GetComponent<Rigidbody>().freezeRotation = true;

        originalRotation = transform.localRotation;
        if(FPSCamera){
            fovTemp = FPSCamera.fieldOfView;
            fovTarget = fovTemp;
        }
    }
    // When recieving other unit's order
    void ContinuePath(CharacterSystem trueFrontUnit)
    {
        Debug.Log("ContinuePath : " + this);
        // Transmit the new back unit to the front units
        Debug.Log("trueFrontUnit : " + trueFrontUnit);
        // Rearange the front unit list for the new back unit
        if (_backUnit != null) {
            /*
            foreach (CharacterSystem frontUnit in _backUnit._frontUnits) {
                frontUnit._backUnit = _backUnit;
            }*/

            _backUnit._frontUnits = _frontUnits;
            if (!_backUnit._frontUnits.Contains(this))
                _backUnit._frontUnits.Add(this);
        }
    }
 public void Set(OrderImpulse order, CharacterSystem originUnit, Vector3 targetPosition)
 {
     _order = order;
     _originUnit = originUnit;
     _targetPosition = targetPosition;
     _integrateUnitFound = false;
 }
 void SendOrder(Order order, CharacterSystem targetUnit)
 {
     if (targetUnit != null) targetUnit.RecieveOrder(order,_originUnit);
 }
 public void SetNewTarget(CharacterSystem newTarget)
 {
     wayPoints = new List<Vector3>();
     wayPoints.Add(newTarget.transform.position);
     currentWaypointId = 0;
 }
    void OnTriggerEnter2D(Collider2D collider)
    {
        if (collider.transform.tag == "unit") {
            if (
               _state == States.WAITING_ORIGIN
               || _state == States.WAITING_TARGET
               || _state == States.TRAVELING
                ) {

                // Retrieve unit to integrate
                CharacterSystem unitToIntegrate = collider.gameObject.GetComponent<CharacterSystem>();

                if (
                    unitToIntegrate != null
                    && (unitToIntegrate == _originUnit || unitToIntegrate == _targetUnit)
                    )
                    return;

                if (unitToIntegrate._frontUnits.Contains(_originUnit))
                    return;

                CharacterSystem.IntegratePathBehindUnit(
                    _originUnit,
                    unitToIntegrate
                    );

                // Remove this order from old target's waiting list
                if (_targetUnit != null)
                    _targetUnit._pendingOrder.Remove(this);

                // Set unit to integrate as new target
                _targetUnit = unitToIntegrate;

                _targetUnit.transform.position = transform.position;
                if (_targetUnit._currentOrder != null)
                    _targetUnit._orderCompleated = true;

                _integrateUnitFound = true;

                // _targetUnit._frontUnits.Add(_originUnit);

                // Add this order to the new target waiting list

                /*
                if (_targetUnit != null)
                    _targetUnit._pendingOrder.Add(this);
                */

                if (_state == States.TRAVELING) {
                    // Desactivate de delay feedback
                    _durationTransform.gameObject.SetActive(false);

                    // Recalculate the particle feedback
                    _particle.SetNewTarget(_targetUnit);

                    return;
                }
            }
        }
    }
 void Start()
 {
     animator = this.GetComponent<Animator>();
     character = this.GetComponent<CharacterSystem>();
 }
    public void RecieveOrder(Order order, CharacterSystem newFrontUnit)
    {
        //
        /*
        if(!_frontUnits.Contains(newFrontUnit) && newFrontUnit != this)
            _frontUnits.Add(newFrontUnit);
            */

        // Check if the order is valide
        if (order == null || order._orderType == Order.OrderType.NULL) {
            if (_pendingOrder.Count > 0) {
                _pendingOrder.RemoveAt(0);
            }
            return;
        }
        ContinuePath(newFrontUnit);
        ExecuteOrder(order);
    }
 void Start()
 {
     networkViewer = this.GetComponent<NetworkView> ();
     character = this.GetComponent<CharacterSystem> ();
 }
Exemple #56
0
    public void InstantiateCharacter(CharacterSystem character, string hasKey)
    {
        Debug.Log ("Instantiat Character save");
        if (character == null)
            return;

        MainCharacter = character;
        if ((!Network.isServer && !Network.isClient) || Network.isServer) {
            PlayerSaveData playersave = new PlayerSaveData ();
            playersave = ReadData (hasKey);

            // Apply data to host
            ApplyPlayerData (playersave);

            // apply data to clients
            if (Network.isServer) {
                if (MainCharacter.networkViewer)
                    MainCharacter.networkViewer.RPC ("ApplyData", RPCMode.Others, PlayerSaveDataText (playersave));
            }
        }

        MainCharacter = null;
    }
    void Start()
    {
        animator = this.GetComponent<Animator> ();
        audioSource = this.GetComponent<AudioSource> ();
        if (this.transform.root) {
            character = this.transform.root.GetComponent<CharacterSystem> ();
            fpsController = this.transform.root.GetComponent<FPSController> ();
            if (character == null)
                character = this.transform.root.GetComponentInChildren<CharacterSystem> ();
            if (fpsController == null)
                fpsController = this.transform.root.GetComponentInChildren<FPSController> ();
        } else {
            character = this.transform.GetComponent<CharacterSystem> ();
            fpsController = this.transform.GetComponent<FPSController> ();
        }
        timeTemp = Time.time;

        if (ItemIndicator) {
            preplacingObject = (GameObject)GameObject.Instantiate (ItemIndicator.gameObject, this.transform.position, ItemIndicator.transform.rotation);
        }
    }
Exemple #58
0
    public void LoadPlayer(CharacterSystem character)
    {
        if (UnitZ.gameManager == null || character == null)
            return;

        MainCharacter = character;
        string hasKey = UnitZ.gameManager.UserID + "_" + Application.loadedLevelName + "_" + UnitZ.gameManager.UserName;
        //Debug.Log("LOAD : HAS KEY "+hasKey);
        if ((!Network.isServer && !Network.isClient) || Network.isServer) {
            PlayerSaveData playersave = new PlayerSaveData ();
            playersave = ReadData (hasKey);
            ApplyPlayerData (playersave);
        } else {
            if (networkViewer)
                networkViewer.RPC ("RequestLoadFromServer", RPCMode.Server, hasKey);
        }
    }
    bool InstantiatePlayerObject(string playerID, string userID, string userName, int index, string team, int spawner)
    {
        if (UnitZ.characterManager == null || UnitZ.characterManager.CharacterPresets.Length < index || index < 0)
            return false;

        characterBase = UnitZ.characterManager.CharacterPresets [index].CharacterPrefab;
        PlayerSpawner[] spawnPoint = (PlayerSpawner[])GameObject.FindObjectsOfType (typeof(PlayerSpawner));

        if (spawner < 0 || spawner >= spawnPoint.Length) {
            spawner = Random.Range (0, spawnPoint.Length);
        }

        if (characterBase && spawnPoint.Length > 0) {
            CharacterSystem character = spawnPoint [spawner].Spawn (characterBase.gameObject).GetComponent<CharacterSystem> ();
            character.Team = team;
            character.UserID = userID;
            character.UserName = userName;
            character.ReceivePlayerID (playerID);

            if (UnitZ.playerSave != null && character != null) {
                string haskey = userID + "_" + Application.loadedLevelName + "_" + userName;
                UnitZ.playerSave.InstantiateCharacter (character, haskey);
            }

            if (playerID == UnitZ.gameManager.PlayerID) {
                playingCharacter = character;
            }
            characterLoaded = false;
            MouseLock.MouseLocked = true;
            return true;
        }
        return false;
    }
    void Awake()
    {
        networkViewer = this.gameObject.GetComponent<NetworkView> ();
        character = this.gameObject.GetComponent<CharacterSystem> ();
        itemManager = (ItemManager)GameObject.FindObjectOfType (typeof(ItemManager));
        if (this.transform.GetComponentsInChildren (typeof(ItemSticker)).Length > 0) {
            var items = this.transform.GetComponentsInChildren (typeof(ItemSticker));
            itemStickers = new ItemSticker[items.Length];
            for (int i=0; i<items.Length; i++) {
                itemStickers [i] = items [i].GetComponent<ItemSticker> ();
                itemStickers [i].ItemIndex = -1;
            }
        }

        PlayerView pv = gameObject.GetComponent<PlayerView> ();
        if (pv && FPSItemView == null) {
            FPSItemView = pv.FPScamera.FPSItemView.GetComponent<ItemSticker> ();
        }

        int shortkey = 0;
        for (int i=0; i< StarterItems.Length; i++) {
            if (StarterItems [i].item != null) {
                AddItemByIdemData (StarterItems [i].item, StarterItems [i].Num, -1,shortkey);
                shortkey++;
            }
        }
        if (Items.Count > 0 && Items [0] != null)
            EquipItemByCollector (Items [0]);
    }