示例#1
0
    public override bool InsertItem(GameObject item)
    {
        RackModule module = item.GetComponent <RackModule>();

        //Check if compatible with this rack type
        if (module == null || module.Type != CompatibleType)
        {
            Debug.Log("This Module is Incompatible with This Rack");
            return(false);
        }

        if (moduleFailed)
        {
            ResetFailedModule();
            GameManager.Instance.PlayerAudio.clip = GameManager.Instance.ServerStart;
            GameManager.Instance.PlayerAudio.Play();
            Destroy(item);

            return(true);
        }

        if (!IsInsertable())
        {
            return(false);
        }

        //int bay = FindFirstAvailableBay();
        //if (bay == -1)
        //Debug.LogError("No Available Bay THIS SHOULDN'T EVER Happen");

        //Add To Rack
        Modules.Add(item);

        //Animation Setup
        Transform bayPos = BayPositions[Modules.Count - 1].transform;

        item.transform.position = bayPos.position + (bayPos.forward * -AnimationStartPosOffset);
        item.transform.rotation = Quaternion.identity;

        item.transform.SetParent(bayPos);

        module.SetAnimationPoints(item.transform.position, bayPos.position);

        GameManager.Instance.PlayerAudio.clip = GameManager.Instance.ServerStart;
        GameManager.Instance.PlayerAudio.Play();

        module.ActivateModule();
        //TODO Sound
        return(true);
    }
    public virtual bool ResetFailedModuleIfExists()
    {
        foreach (GameObject obj in hardDrives)
        {
            RackModule rm = obj.GetComponent <RackModule>();
            if (!rm.Active)
            {
                rm.ResetModule();
                rm.ActivateModule();
                return(true);
            }
        }

        return(false);
    }
示例#3
0
    protected virtual void ResetFailedModule()
    {
        foreach (GameObject obj in Modules)
        {
            RackModule rm = obj.GetComponent <RackModule>();
            if (!rm.Active)
            {
                rm.ResetModule();
                rm.ActivateModule();
                moduleFailed = false;
                smokeEffect.Stop();
                return;
            }
        }

        Debug.LogError("Tried to reset a module but none appear damaged");
    }